我想摆脱我的数组中的重复项,但我仍然打印重复项:
$getuser = ltrim($top10['url'], " users/" ); //trim url to get user id
$array[$i++] = $getuser;
$dirty = $array;
$clean = array_unique($dirty);
print_r($clean)."<br />";
输入print_r($array)
Array ( [0] => 33 [1] => 3 [2] => 29 [3] => 3104 ) Array ( [0] => 156686 [1] => 5 [2] => 3104 [3] => 1 ) Array ( [0] => 2 [1] => 115023 [2] => 185367 [3] => 180694 ) Array ( [0] => 2 [1] => 5 [2] => 3104 [3] => 139403 ) Array ( [0] => 3110 [1] => 2723 [2] => 8087 [3] => 97410 ) Array ( [0] => 1925 [1] => 60 [2] => 18995 [3] => 2940 ) Array ( [0] => 103205 [1] => 111503 [2] => 2 [3] => 128715 ) Array ( [0] => 3 [1] => 119266 [2] => 4 [3] => 3104 ) Array ( [0] => 32565 [1] => 2743 [2] => 148584 [3] => 3505 ) Array ( [0] => 35282 [1] => 99136 [2] => 54167 [3] => 5326 )
输出print_r($clean)
;
Array ( [0] => 33 [1] => 3 [2] => 29 [3] => 3104 ) Array ( [0] => 156686 [1] => 5 [2] => 3104 [3] => 1 ) Array ( [0] => 2 [1] => 115023 [2] => 185367 [3] => 180694 ) Array ( [0] => 2 [1] => 5 [2] => 3104 [3] => 139403 ) Array ( [0] => 3110 [1] => 2723 [2] => 8087 [3] => 97410 ) Array ( [0] => 1925 [1] => 60 [2] => 18995 [3] => 2940 ) Array ( [0] => 103205 [1] => 111503 [2] => 2 [3] => 128715 ) Array ( [0] => 3 [1] => 119266 [2] => 4 [3] => 3104 ) Array ( [0] => 32565 [1] => 2743 [2] => 148584 [3] => 3505 ) Array ( [0] => 35282 [1] => 99136 [2] => 54167 [3] => 5326 )
答案 0 :(得分:0)
是的,似乎是正确的。基本上你指定了一个array_unique
的数组,它为你提供了数组中的唯一项目。
$unique_array = array_unique($your_array);