PHP array_values() Function

Definition

The array_values() returns an array of all the values.

Syntax

PHP array_values() Function has the following syntax.

array array_values ( array arr )

Using the array_values() function makes PHP create a new array where the indexes are recreated and the values are copied from the old array.

Parameter

  • array - Required. Specifying an array

Example

Returns an array of all the values


<?PHP//from  w  w  w  . j a v  a  2 s . c om
$words = array("Z","A", "B", "C", "D", "java2s.com");

var_dump($words);
asort($words);
var_dump($words);
var_dump(array_values($words));
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions