PHP array_values() Function: Usage & Examples
The array_values() function in PHP is used to return a new array containing all the values from the original array. It reorders the array indexes and returns a new array with indexes starting from 0.
Here is the syntax of the array_values() function:
Return an indexed array containing the values of the input array.
Among them, array is the array that needs to be returned.
原文:我想购买这本书。
重述:I would like to purchase this book.
$colors = array("red", "green", "blue");
$values = array_values($colors);
print_r($values);
Output:
Array
(
[0] => red
[1] => green
[2] => blue
)
In the mentioned example, $values is a new array containing all values from the $colors array, with the indexes starting from 0 and increasing sequentially.