Two php methods are used to remove duplicate items of two-dimensional arrays, and two php methods are used to remove two-dimensional arrays. Two php methods to remove duplicate items from two-dimensional arrays, and two php methods to remove duplicate values from two-dimensional arrays. the code is as follows: Method 1: two-dimensional array remove two php methods to remove two-dimensional array duplication, two php methods to remove two-dimensional array
Php removes the duplicate values of two-dimensional arrays. the code is as follows:
Method 1:
// Remove the duplicate value from the two-dimensional array function array_unique_fb ($ array2D) {foreach ($ array2D as $ v) {$ v = join (',', $ v ); // reduce the dimension. you can also use implode to convert a one-dimensional array to a comma-connected string $ temp [] = $ v ;}$ temp = array_unique ($ temp ); // remove the duplicate string, that is, the repeated one-dimensional array foreach ($ temp as $ k => $ v) {$ temp [$ k] = explode (',', $ v); // re-assemble the split array} return $ temp ;}
Method 2:
// Remove duplicate values from the two-dimensional array and retain the key value function array_unique_fb ($ array2D) {foreach ($ array2D as $ k = >$ v) {$ v = join (', ', $ v); // dimension reduction. you can also use implode to convert a one-dimensional array to a comma-connected string $ temp [$ k] = $ v ;} $ temp = array_unique ($ temp); // remove the duplicate string, that is, the repeated one-dimensional array foreach ($ temp as $ k => $ v) {$ array = explode (',', $ v ); // re-assemble the split array // modify the following indexes as needed. $ temp2 [$ k] ['id'] = $ array [0]; $ temp2 [$ k] ['title'] = $ array [1]; $ temp2 [$ k] ['keyword'] = $ array [2]; $ temp2 [$ k] ['content'] = $ array [3];} return $ temp2 ;}
The two php methods to remove duplicate items of two-dimensional arrays have their own advantages and disadvantages. you can choose one based on your situation.
The method for removing duplicate values of two-dimensional arrays in php is summarized as follows: Method 1: // remove two-dimensional arrays...