Home >Backend Development >PHP Problem >How to remove key names from array in php
php method to remove the key name of the array
In PHP, you can use the array_values() function to remove the array key name.
Definition and usage
array_values() function returns an array containing all the values in the array.
Tip: The returned array will use numeric keys, starting from 0 and increasing by 1.
Syntax
array_values(array)
Parameters: array required. Specifies an array.
Return value: Returns an array containing all the values in the array.
PHP Version: 4
Example
Return all values in the array (key names are not retained):
<?php $a=array("Name"=>"Peter","Age"=>"41","Country"=>"USA"); print_r(array_values($a)); ?>
Output :
Array ( [0] => Peter [1] => 41 [2] => USA )
Recommended: "PHP Tutorial"
The above is the detailed content of How to remove key names from array in php. For more information, please follow other related articles on the PHP Chinese website!