print_r($tokens);
$tokens = array_unique($tokens);
print_r($tokens);
Gives the following output:
Array
(
[0] => Array
(
[Class_ID] => 32709
)
[1] => Array
(
[Class_ID] => 34682
)
[2] => Array
(
[Class_ID] => 34818
)
)
Array
(
[0] =&g开发者_运维百科t; Array
(
[Class_ID] => 32709
)
)
I don't want it to be changing anything with that array_unique, since the Class_ID values are different.. whats up?
From documentation:
Note: Two elements are considered equal if and only if
(string) $elem1 === (string) $elem2
In words: when the string representation is the same. The first element will be used.
All your elements toString
are Array
.
Found a function from php.net that does array_unique on multi-dimensional arrays:
function super_unique($array) //array unique for multi
{
$result = array_map("unserialize", array_unique(array_map("serialize", $array)));
foreach ($result as $key => $value)
{
if ( is_array($value) )
{
$result[$key] = super_unique($value);
}
}
return $result;
}
精彩评论