View Single Post
Old 07-15-2008, 12:10 PM   #4 (permalink)
benton
The Contributor
 
Join Date: Apr 2008
Posts: 78
Thanks: 0
benton is on a distinguished road
Default

Quote:
Originally Posted by drewbee View Post
I believe asort is what your looking for.
PHP Code:
$array = array('1' => array('52' => 'Milk Choclate',
                            
'221' => 'Vanilla Bean',
                            
'212' => 'Banana Cream',
                            
'80' => 'Choclate Peanut Butter'));

asort($array['1']);
echo 
print_r($array); 

I am not to sure if this is exactly what you are looking for. If you could provide a more accurate example as if I were to build a recursive function for this (multi-dim array);

It would need to start at the deepest array and work back to the beginning (what string value does an array have?) if you see what I mean.
I don't understand what you mean by "what string value..." but I added the following based on what you said and it works great. But it doesn't do it backwards so I'm wondering if it OK to use?
PHP Code:
         for ($i 0$i count($myarray); ++$i)
         {
           if (
is_array($myarray[$i]))
             
asort($myarray[$i]);
         } 
benton is offline  
Reply With Quote