Home >Backend Development >PHP Tutorial >Array_unique removes duplicate arrays from a two-dimensional array in php_PHP tutorial
A method to use array_unique in PHP to remove duplicate values from secondary arrays. Friends in need can refer to it.
The code is as follows
|
Copy code
|
||||
//$result = array_unique($input); //Remove duplicate elements $result = a_array_unique($input);?? //Only a single element left foreach($result as $aa) { echo $aa.” ”; } function multi_unique($array) { foreach ($array as $k=>$na) $new[$k] = serialize($na); $uniq = array_unique($new); foreach($uniq as $k=>$ser) $new1[$k] = unserialize($ser); return ($new1); } |