Home > Article > Backend Development > How to use array_values function in php
Usage of array_values function in php: [array_values(array)]. The array_values function is used to return an array containing all key values in the given array, without retaining the key names.
php The array_values function returns all values (non-key names) of the array. Its syntax is array_values(array). The parameter array is required and refers to the specified array.
(Recommended tutorial: php video tutorial)
How to use the php array_values function?
Function: Return all values (non-key names) of the array
Syntax:
array_values(array)
Parameters:
array required. Specifies an array.
Description:
Returns an array containing all key values in the given array, but does not retain the key names. The returned array will use numeric keys, starting at 0 and increasing by 1.
php array_values() function usage example 1
<?php $a = array("class" => "php中文网","name" => "西门","job" => "讲师"); print_r(array_values($a)); ?>
Output:
Array ( [0] => php中文网 [1] => 西门 [2] => 讲师 )
php array_values() function usage example 2
<?php $a = array("class" => "php中文网","name" => "无忌哥哥","job" => "考官"); print_r(array_values($a)); ?>
Output:
Array ( [0] => php中文网 [1] => 无忌哥哥 [2] => 考官 )
The above is the detailed content of How to use array_values function in php. For more information, please follow other related articles on the PHP Chinese website!