In PHP, you can use the "array_values" function to set the array without key names. This function is used to return an array containing all the values in the array. The returned array will remove the original key names and use numerical keys. The syntax is "array_values(array)".
The operating environment of this article: Windows 10 system, PHP version 7.1, Dell G3 computer.
array_values() function returns an array containing all the values in the array.
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.
Examples are as follows:
<?php $a=array("Name"=>"Peter","Age"=>"41","Country"=>"USA"); print_r(array_values($a)); ?>
Output results:
## Recommended learning: "PHP Video Tutorial 》
The above is the detailed content of How to set the array in php without the original key name. For more information, please follow other related articles on the PHP Chinese website!