PHP array_values() Function
In this chapter you will learn:
- Definition for PHP array_values() Function
- Syntax for PHP array_values() Function
- Parameter for PHP array_values() Function
- Example - returns an array of all the values
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/* j a v a 2s . co m*/
$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.
Next chapter...
What you will learn in the next chapter:
- Definition for PHP array_walk() Function
- Note for PHP array_walk() Function
- Syntax for PHP array_walk() Function
- Parameter for PHP array_walk() Function
- Example - Map an array with user defined function
- Example - With a parameter
- Example - Change an array element's value. (using the &$value)
Home » PHP Tutorial » PHP Array Functions