This article mainly introduces php two-dimensional array merging and deduplication methods. The example analyzes php's techniques for merging arrays and deleting repeated items. For more information, see
This article mainly introduces php two-dimensional array merging and deduplication methods. The example analyzes php's techniques for merging arrays and deleting repeated items. For more information, see
This article describes how to merge and deduplicate two-dimensional php arrays. 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.