I have an array that I need to sort by an associative key. PHP's usort
() function is what I need, however it won't work inside a controller.
Example:
function cmp($a, $b)
{
return strcmp($a["fruit"], $b["fruit"]);
}
$fruits[0]["fruit"] = "lemons";
$fruits[1]["fruit"] = "apples";
$fruits[2]["fruit"] = "grapes";
usort($fruits, "cmp");
I am pretty sure the reason it doesn't work, is because I would have
to call $this->cmp(), not just cmp() like the function is probably
doing. Anyone have any idea how to get around this? Or a better way to
sort arrays by key in Cake?
Thanks!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---