PHP 我有兩個單一的數組,填充從兩個表,與ID。從一個數組中,我需要能夠在出現多個X數的情況下刪除所有ID相同的值。 我這樣做:陣列刪除重複的條目,他們超過一個X值
volunteerRoleQuery = mysql_query("SELECT member_no, role_code, volunteer_date FROM evntrole WHERE volunteer_date > '$today' ");
$numberEvntRole = mysql_numrows($volunteerRoleQuery);
while ($row = mysql_fetch_assoc($volunteerRoleQuery)) {
$member_no = $row["member_no"];
array_push($volunteersArray, $member_no);
}
fputcsv($output, array('Member number', 'Full name', 'First name', 'Surname', 'Email', 'Mobile', 'Phone'));
$teamMemQuery = mysql_query("SELECT member_number, activity_code, modify_date FROM teammem WHERE modify_date > '$today' ");
$numberTeamMem = mysql_numrows($teamMemQuery);
if ($numberTeamMem > 0) {
while ($row = mysql_fetch_assoc($teamMemQuery)) {
$member_no = $row["member_number"];
array_push($teamMemArray, $member_no);
}
}
// TODO:只保留會員ID的比X事件多,說3 //如1,1,2,3,3,3,3,6,7 ,7,7,7將只保留3,7 //這將確保我們不要求成員自願如果僅僅做了一些事件。
該數組可能如下所示: 1,1,1,4,4,5,6,7,7,7,7等如果X值爲3,則只剩下7個。 任何例子都會很棒。 – 2013-03-20 23:31:49