Re: Array sort question
| From: | Robin Vickery | Date: | Tue, 28 Feb 2006 20:54:49 +0000 |
| Subject: | Re: Array sort question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-231232@lists.php.net to get a copy of this message | ||
On 28/02/06, jblanchard@onecallcom.com <jblanchard@onecallcom.com> wrote:
> The array sorting suggestions you provide will not sort based on the
> number of items in each array, which is what the OP wanted.
That's not entirely fair. I would have said his usort() suggestion was
a better pointer than a link to count() - which gives no hint as to
how to sort the list, which is after all what the OP's trying to do.
ObSuggestion:
function byLength($a, $b)
{
return sizeof($a) - sizeof($b);
}
usort($rgArray, 'byLength');