henryhenry Posted May 9, 2007 Share Posted May 9, 2007 HelloI am trying to use uasort for an array like this (first code box). I am trying to have it ordered by the rank, keeping the array keys and structure the same. When I run it in my code, I get bool(true) result, rather than another array. I can't see where I'm going wrong... $array is - [0] =>- - [item] => hello- - [rank] => 20- [1] =>- - [item] => world- - [rank] => 35- [2] =>- - [item] => help- - [rank] => 23 The compare function I'm trying is as on php.net (but I added ['rank']) function compareRank($a, $b) { if ($a['rank'] == $b['rank']) { return 0; } return ($a['rank'] < $b['rank']) ? -1 : 1; } My code has the following in it: $array= uasort($array, "compareRank"); Thanks!!! Link to comment Share on other sites More sharing options...
henryhenry Posted May 9, 2007 Author Share Posted May 9, 2007 OK - spot the idiot who didn't read the article on php.net properly. Now I see that you don't need to output the result, it does it automatically. Sorry! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.