|
Posted by Rik on 08/23/06 10:42
annmartinson@gmail.com wrote:
> No idea why this works, but I do appreciate it very much. plugged it
> in, works like a charm. thanks!!
Well for future reference, you may need another sort, so a short
explanation:
usort($array,'function_name');
function_name is the custom name of a function to sort by. This function
will get 2 variables to compare, $a and $b, which are 2 values from your
array, so in this case:
$a = array('id'=>1,'name'=>'fire,'value'=>0);
Likewise for b.
This function will have to return either:
0 when sorting should return equals.
-1 when $a should go before $b
1 when $a should come after $b
Now we only want to sort on the 'value' key, so we in the function we only
compare the 'value' key of 'a' and 'b'. In normal sorting, the whole array
$a and $b are compared.
Grtz,
--
Rik Wasmus
[Back to original message]
|