View Single Post
Old 07-15-2008, 12:32 PM   #6 (permalink)
abiko
The Contributor
 
abiko's Avatar
 
Join Date: Feb 2008
Location: Croatia
Posts: 90
Thanks: 4
abiko is on a distinguished road
Default

Is this a solution to your problems?
PHP Code:
<?php

$array 
= array(   '1' =>  array(  '21'  =>  'Item 1',
                                  
'928' =>  'Item what!?!',
                                  
'86'  =>  'Too late item',
                                  
'153' =>  'What is happening here?!?'

                                
),
                  
'2' =>  array(  '997' =>  'Fruit - apple'
                                  
'77' => 'Another fruit - orange',
                                  
'4'   =>  'The icky fruit',
                                  
'64'  =>  'Watermelon'
                                
)
                );
                
/*
 *  Sort the items
 */
 
 
foreach ( $array as $row => $data) {
      
ksort$data);
      
$_compile[$row] =  $data;
 
 } 
 
 
/*
  * output
  */
  
  
echo "<h1>First array</h1>";
  
print_r $array);
  
  echo 
"<h1>The compiled array</h1>";
  
print_r$_compile );                  
      

?>
Output
Code:
Array
(
    [1] => Array
        (
            [21] => Item 1
            [86] => Too late item
            [153] => What is happening here?!?
            [928] => Item what!?!
        )

    [2] => Array
        (
            [4] => The icky fruit
            [64] => Watermelon
            [77] => Another fruit - orange
            [997] => Fruit - apple
        )

)
__________________
Back from sysadmins to the programmers.
Send a message via ICQ to abiko Send a message via MSN to abiko
abiko is offline  
Reply With Quote