array_values
array array_values(array array)
Returns all values from an array.
Returns:
Indexed array containing all values from another array; NULL on failure
Description:
This function simply returns an indexed array in which each element is the corresponding element from array . The returned array is consecutively indexed starting from 0; all keys from the original array are ignored.
One use for this function is to quickly collapse an array that has had some elements unset using unset() into a freshly-ordered indexed array with no blank entries.
Version:
PHP 4
Example:
Get the values from an array
$array = array(1, 2, 3, 5, 7, 11, 13, 17, 19, 23); unset($array[3]); unset($array[7]); echo "Original array:\n"; print_r($array); $arr2 = array_values($array); ... |
Get PHP Functions Essential Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.