PHP array_values() Function
PHP array_values() Function
The array_values () function in PHP returns all the values from the array and indexes the array numerically.
Syntax
array_values ( array $array )
Parameter
array(required)- This array represents the input array.
Return
This function returns an indexed array of values.
Example 1
Output
Input Array: Array ( [0] => a [1] => b [2] => c [3] => d [4] => e )
Example 2
Output
Input Array: Array ( [0] => apple [1] => banana [2] => dates [3] => eggfruit )
Example 3
Output
Input Array: Array ( [0] => )
Example 4
"green", "red", "b" => "green", "blue", "red"); echo("Input Array: \n"); //will return the values of the array print_r(array_values($array)); ?>
Output
Input Array: Array ( [0] => green [1] => red [2] => green [3] => blue [4] => red )