Re: multidimensional array sort

From: Date: Tue, 15 Mar 2005 02:29:19 +0000
Subject: Re: multidimensional array sort
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-210735@lists.php.net to get a copy of this message
Leif Gregory wrote:
http://us3.php.net/manual/en/function.array-multisort.php I did go through that, but I can't get it to work and I'm almost willing to bet it's because of the way the array is built. For example, the example on that page says that I should be able to do a sort on $ar[0] and $ar[1], however in my array both of those return 0. In fact, when I do this:
     echo "items in array: " . count($data) . "<br />";         for ($i = 0; $i < count($data); $i++) {
       echo "data[$i]: " . count($data[$i]) . "<br />";
     }
I get:
     items in array: 2
     data[0]: 0
     data[1]: 0
When I do a print_r($data), I get:
     Array
       (
          [John] => Array
             (
                [KIRASH] => Array
                  (
                     [0] => 050311_18.00.59__KIRASH.zip
                     [1] => 050311_18.10.20__KIRASH.zip
                  )
                [MCCROY] => Array
                  (
                     [0] => 050312_20.52.28__MCCROY.zip
                  )
             )
          [Ron] => Array
             (
                [EMBROR] => Array
                  (
                     [0] => 050314_15.47.56__EMBROR.zip
                  )
             )
       )
Soooo, I'm at a loss here. I think I need to create the array differently for it to work. -- H | I haven't lost my mind; it's backed up on tape somewhere. +-------------------------------------------------------------------- Ashley M. Kirchner <mailto:ashley@pcraft.com> . 303.442.6410 x130 IT Director / SysAdmin / WebSmith . 800.441.3873 x130 Photo Craft Imaging . 3550 Arapahoe Ave. #6 http://www.pcraft.com ..... . . . Boulder, CO 80303, U.S.A.

« previous php.general (#210735) next »