hello there,
running php 4.4.7
im trying to load staff member information from a database, and currently i divide them into a multidimensional array based on committee. i want to sort the array containing objects based on a property of the objects: i want the committee chairman to be the first value in the corresponding committee's array. currently this is the code i use to load the committee members:
function getAllStaffByCommittee(){
global $staff;
$q = "SELECT * "
." FROM ".TBL_USERS." as users, ".TBL_STAFF." as staff "
."WHERE "
." (staff.status = '".STATUS_UNCONFIRMED."' "
." || staff.status = '".STATUS_AUTHENTICATED."') & (users.id = staff.user_id) & "
." (users.userlevel = '".STAFF_MEMBER_LEVEL."' "
." || users.userlevel = '".STAFF_CHAIR_LEVEL."') ORDER BY staff.id";
if(!($result = mysql_query($q))){
die(mysql_error());
}else{
if(!mysql_num_rows($result) > 0){
return false;
}
$allStaff = array();
$comms = explode(",", COMMITTEE_CHOICES);
while($resObj = mysql_fetch_object($result)){
$staff = new Staff;
$staff->loadStaffMember($resObj->id);
foreach($comms as $comm){
if($comm == $staff->committee['assign']){
$allStaff[$comm][$staff->id] = $staff;
}
}
}
return $allStaff;
}
}
the sorting should be based on this property: (bool)$staff->committee['chair'],
or inside the multidimensional array: $allStaff[committee][id]->committee['chair']
i think i have to use array_multisort(), but there aren't really any examples using a property of an object in an array to sort by. any help is greatly appreciated! thanks!
take care,