The array_values
method in PHP returns all of the values of the
array_values($array): array
The array_values
method returns an array.
<?php$age_array = array("Rahum" => 12, "Ram" => 22);print_r( array_values( $age_array));?>
In the code above, we create an array with the name age_array
and call the array_values
method.
The array_values
method returns a new array with all values of age_array
. The indexing of the returned array will be based on default numeric indexing.
<?php$multi_array = array('one' => 1,'two' => array('one' => 2, 'two' => 22));print_r( array_values( $multi_array));?>
In the above code, we create a multidimensional array with multi_array
and call the array_values
method. The array_values
method will return a new array with all values of multi_array
.