Hi,
Can someone please put me out of my misery and tell me why this will sort by $user_total_posts:
$top_posters[] = array('user_id' => 1, 'user_total_posts' => 993);
$top_posters[] = array('user_id' => 2, 'user_total_posts' => 209);
$top_posters[] = array('user_id' => 3, 'user_total_posts' => 2);
$top_posters[] = array('user_id' => 4, 'user_total_posts' => 4);
$top_posters[] = array('user_id' => 5, 'user_total_posts' => 90);
$top_posters[] = array('user_id' => 6, 'user_total_posts' => 25);
foreach ($top_posters as $key => $value)
{
$user_id[$key] = $value['user_id'];
$user_total_posts[$key] = $value['user_total_posts'];
}
array_multisort($user_total_posts, SORT_DESC, $user_id, SORT_ASC, $top_posters);
print_r($top_posters);
but this wont:
$SQL = "SELECT * FROM " . USERS_TABLE . "";
$results = ExeSQL($SQL);
while ($row = mysql_fetch_array($results))
{
$user_id = $row["user_id"];
$user_total_posts = user_total_posts(&$user_id);
$top_posters[] = array('user_id' => $user_id, 'user_total_posts' => $user_total_posts);
}
foreach ($top_posters as $key => $value)
{
$user_id[$key] = $value['user_id'];
$user_total_posts[$key] = $value['user_total_posts'];
}
array_multisort($user_total_posts, SORT_DESC, $user_id, SORT_ASC, $top_posters);
print_r($top_posters);
Thanks