Sorting Array with User Id
-
I’ve got a function that that retrieves all the user names along with the number of published posts. Then, I put both of those variables into an array. This works great, but I would like to sort the array by the number of posts. So in this case sort it by the Value.
I know there is a asort(), but it does not to seem have effect on the order of the array.
Not sure what I’m doing wrong.
Thanks, the code is below.
$data = array($nickname => $num_rows);
arsort($data);
foreach ($data as $key => $value) {
echo $key . ‘ : ‘ . $value. ‘
‘;
}
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Sorting Array with User Id’ is closed to new replies.