(
<?php
function FetchRepeatMemberInArray($array) {
// 獲取去掉重復數據的數組
$unique_arr = array_unique ( $array );
// 獲取重復數據的數組
$repeat_arr = array_diff_assoc ( $array
return $repeat_arr;
}
// 測試用例
$array = array (
);
$repeat_arr = FetchRepeatMemberInArray ( $array );
print_r ( $repeat_arr );
?>
(
<?php
function FetchRepeatMemberInArray($array) {
$len = count ( $array );
for($i =
for($j = $i +
if ($array [$i] == $array [$j]) {
$repeat_arr [] = $array [$i];
break;
}
}
}
return $repeat_arr;
}
// 測試用例
$array = array (
);
$repeat_arr = FetchRepeatMemberInArray ( $array );
print_r ( $repeat_arr );
?>
From:http://tw.wingwit.com/Article/program/PHP/201311/20965.html