PHP method to remove key names and merge arrays: first define an array with key names, and then define two other similar arrays with different key names; then use the [array_merge] method to merge; finally use [ array_values] method can discard the original key name.
PHP method to remove key names and merge arrays:
#1. Define an array with key names, such as Picture an array like this.
2. Define two other similar arrays with different key names.
3. To merge arrays, we just use the array_merge method to merge them.
#4. After merging, we output the results.
5. It can be seen from the results that if you merge directly like this, the key names of the array will also be merged.
6. 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.
7. After modification, rerun, 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.
Related learning recommendations:PHP programming from entry to proficiency
The above is the detailed content of How to remove key names from merged arrays in PHP?. For more information, please follow other related articles on the PHP Chinese website!