How to realize the deduplication of two-dimensional array by PHP
This article mainly introduces PHP how to achieve two-dimensional array deduplication, the article introduces in great detail, has a certain reference value, interested friends must read it!
Two-dimensional array deduplication
$arr = array (array ('id'= >' 2century grammatical title = > '...', 'ding'= >' 1century relegated calendar = > '...', 'url'= >'...', 'dj'= >'...'), array ('id'= >' 2Zongzhengzhengqiang = > '...', 'ding'= >' 1Zongzhengjingfang = > '1century paranormal timekeeper = >'...', 'url'= >'...'. 'dj'= >'...')) Function about_unique ($arr=array ()) {/ * treats the two-dimensional array as an one-dimensional array, then only one is left if the value of the one-dimensional array is the same, and the one-dimensional array is returned with a rearranged indexed array, and each element in the returned one-dimensional array is an associative array formed by the original key value * / $keys = array (); $temp = array () Foreach ($arr [0] as $k = > $arrays) {/ * the key value of the associative array recorded in the array * / $keys [] = $k;} / / return $keys; / * dimensionality reduction * / foreach ($arr as $k = > $v) {$v = join (",", $v); / / dimensionality reduction $temp [] = $v;} $temp = array_unique ($temp) / / remove duplicates foreach ($temp as $k = > $v) {/ * reassemble the disassembled array into an indexed array * / $temp [$k] = explode (",", $v);} / / return $temp; / * reassemble the disassembled array according to the associated array key value * / foreach ($temp as $k = > $v) {foreach ($v as $kkk= > $ck) {$data [$k] [$keys [$kkk]] = $temp [$k] [$kkk] }} return $data;} these are all the contents of the article "how to remove duplicates in two-dimensional arrays by PHP". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!