如何使用PHP消除数组中的重复,数组如下所示
[1] => Array
(
[name] => Dean
[s_id] => 1
[surname] =>
[id_nr] => 84934568321
[student_nr] => 0
[createdate] => 0000-00-00
[enddate] => 0000-00-00
[count_absent] => 3
)
[2] => Array
(
[name] => Dean
[s_id] => 1
[surname] =>
[id_nr] => 84934568321
[student_nr] => 0
[createdate] => 0000-00-00
[enddate] => 0000-00-00
[count_absent] => 3
)
[3] => Array
(
[name] => Dean
[s_id] => 1
[surname] =>
[id_nr] => 84934568321
[student_nr] => 0
[createdate] => 0000-00-00
[enddate] => 0000-00-00
[count_absent] => 3
)
[4] => Array
(
[name] => Dean
[s_id] => 1
[surname] =>
[id_nr] => 84934568321
[student_nr] => 0
[createdate] => 0000-00-00
[enddate] => 0000-00-00
[count_absent] => 3
)
答案 0 :(得分:9)
在PHP中使用array_unique($array)
你也可以迭代数组并手动比较
答案 1 :(得分:3)
答案 2 :(得分:3)
http://php.net/manual/en/function.array-unique.php
$input = array("a" => "green", "red", "b" => "green", "blue", "red");
$result = array_unique($input);
print_r($result);