Re: sort an array by subarray?
| From: | Daniel Convissor | Date: | Mon, 16 Oct 2000 05:14:38 +0000 |
| Subject: | Re: sort an array by subarray? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-20299@lists.php.net to get a copy of this message | ||
Uh, hi unnamed mystery person who doesn't say please or thanks:
> Does PHP have a function that sorts an array of sub-arrays by a key or
> value of the subarrays? Also is there a way to make user defined sorts so
> all the functions can be within a class? Making the cmp-function something
> like '$this->my_cmp' doesn't seem to work. :)
Your question is kind of fuzzy. But, I think you want this:
$things["garments"] = "hat";
$things["garments"] = "cape";
$things["garments"] = "shirt";
asort($things["garments"]);
If you want something more complex, check out array_multisort() and/or
array_walk().
Enjoy,
--Dan
--
PHP scripts that make your job easier
http://www.analysisandsolutions.com/code/
SQL Solution | Layout Solution | Form Solution
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
4015 7 Ave, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409