尝试按屏幕名称按此多维数组排序:
//Looping through this for each member of a group
unset($member_info);
$member_info->id = $member->id;
$member_info->screen_name = $member->screen_name;
$member_info->first_name = $member->first_name;
$member_info->last_name = $member->last_name;
$member_info->email = $member->email;
//Sort member_info by screen name
$member_array = sort_by_array_key($member_info,$member_info->screen_name,'ASC');
$member_list[] = $member_array;
排序功能:
function sort_by_array_key($array,$sort_key,$dir = 'ASC') {
usort($array, function($a,$b) use ($sort_key){
return strnatcasecmp($a["$sort_key"], $b["$sort_key"]);
});
if ( $dir == 'DESC' ) { return array_reverse($array); }
else { return $array; }
}
例如,即使在我运行排序功能之后,屏幕名称当前也是如此:
newUser
Chris
Carlos
Jason
我可能在错误的时间应用了这种排序,但是在这里查看了其他类似的示例后,我遇到了麻烦,感谢您的帮助,谢谢!