This article mainly introduces the php two-dimensional array merging and deduplication methods. The example analyzes the php techniques for merging arrays and deleting repeated items, for more information about how to merge and deduplicate two-dimensional php arrays, see the example in this article. Share it with you for your reference. The specific implementation method is as follows:
$ Arr = array_merge ($ labels, $ label); // merge the two arrays to be merged $ key = id; // deduplicate condition $ tmp_arr = array (); // declare the array foreach ($ arr as $ k => $ v) {if (in_array ($ v [$ key], $ tmp_arr )) // search for $ v [$ key] in the $ tmp_arr array. If yes, return true {unset ($ arr [$ k]). // delete the array with the same ID in the array ($ arr)} else {$ tmp_arr [] = $ v [$ key]; // record the existing id} dump ($ arr );
I hope this article will help you with php programming.