Home > Article > Backend Development > How to remove key name from php array
In php, you can use the array_values() function to remove the key in the array, the syntax format is "array_values(array)". The array_values() function returns an array containing all the key values in the given array, but does not retain the key names; the returned array will use numeric keys.
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
php remove the key name from the array and return All key values in the array
<?php $a=array("Name"=>"Peter","Age"=>"41","Country"=>"USA"); print_r(array_values($a)); ?>
Output:
Array ( [0] => Peter [1] => 41 [2] => USA )
Description:
rray_values() function returns An array containing all key values in the given array, but without retaining key names.
Tip: The returned array will use numeric keys, starting from 0 and increasing by 1.
Syntax
array_values(array)
Return value
Returns an array containing all the values in the array.
Recommended study: "PHP Video Tutorial"
The above is the detailed content of How to remove key name from php array. For more information, please follow other related articles on the PHP Chinese website!