Example 1
| The code is as follows |
Copy Code |
function My_array_unique ($array 2D) {
foreach ($array 2D as $v) { $v = Implode (",", $v); $temp [] = $v; } $temp = Array_unique ($temp); foreach ($temp as $k => $v) { $temp [$k] = Explode (",", $v); } return $temp; } |
Here's a very nice way to remove a two-dimensional array of duplicate-value functions
| The code is as follows |
Copy Code |
function A_array_unique ($array)//write Better { $out = Array (); foreach ($array as $key => $value) { if (!in_array ($value, $out)) { $out [$key] = $value; } } return $out; } |
The use of the method is also of course simple as
| The code is as follows |
Copy Code |
$array 2D = Array (' title ' => ' 1111′, ' date ' => ' 2222′ '), ' second ' =>array (' title ' => ' 1111′ ', ' =>array ') Date ' => ' 2222′), ' third ' =>array (' title ' => ' 2222′, ' date ' => ' 3333′)); |
Call method
| The code is as follows |
Copy Code |
$as = A_array_unique ($array 2D); Print_r ($as); |
can be done.