Home > Article > Backend Development > How to remove key names from php array
How to remove key names from PHP arrays: first define an array with key names; then use the "array_values" method to take out the array with key names; finally use the "array_merge" method to merge into a new array. .
PHP removes key names and merges arrays
Define an array with key names, as shown in the figure.
Recommended: "PHP Tutorial"
Define another two similar arrays, key names They are all different.
To merge arrays, we just use the array_merge method to merge.
After merging, we output the results.
It can be seen from the results that if you merge directly like this, the key names of the array will also be merged.
Therefore, before merging, we need to take out the array with key names first. You can use the array_values method, which will discard the original key names. of.
After modification, re-run, you can see that the key names of the original array are gone. The resulting new array uses numbers as keys, starting from serial number 0.
The above is the detailed content of How to remove key names from php array. For more information, please follow other related articles on the PHP Chinese website!