我用它来按生日获取朋友列表:
$frnd = $facebook ->api('/me/friends?fields=id,name,birthday&access_token='.$access_token);
如何对结果进行排序并仍将其保持在相同的结构下?
感谢您的评论 - 这帮助我找到了正确的方向,这就是答案:
$frnd = $facebook ->api('/me/friends?fields=id,name,birthday&access_token='.$access_token);
$arr = $frnd["data"];
function so ($a, $b) {
$a_dt = explode("/",$a['birthday']); // dt[0] is month, dt[1] is day
$b_dt = explode("/",$b['birthday']); // dt[0] is month, dt[1] is day
$a_dt_time = mktime(0,0,0,$a_dt[0],$a_dt[1], date("y"));
$b_dt_time = mktime(0,0,0,$b_dt[0],$b_dt[1], date("y"));
return ($a_dt_time < $b_dt_time) ? -1 : 1;
}
uasort($arr, 'so');
$frnd["data"] = $arr;
// debug: print_r($arr);