logo
Apache Lounge
Webmasters

 


About

Forum Index Downloads Search Register Log in  RSS Apache Lounge
 



Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Apache Lounge is not sponsored.

Your donations will help to keep this site alive and well, and continuing building binaries.



[PHP][source] Sort multi array

 
Post new topic   Reply to topic    Apache Forum Index -> Coding & Scripting Corner



View previous topic :: View next topic  
Author Message
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 6255
Location: Germany, Next to Hamburg

PostPosted: Wed 26 Jul '06 14:10    Post subject: [PHP][source] Sort multi array Reply with quote

If some one from you need to sort an array like this

$ary_adps['arry_index_number']['adp_id']['vorname']['name']['url']['homepage']['strasse']['plz']['ort']['profil']['dist']['adresse'];
means
$ary_adps['adp_id']['vorname']['name']['url']['homepage']['strasse']['plz']['ort']['profil']['dist']['adresse'];
Sortieren will

Code:

function columnSort($unsorted, $column) {
   $sorted = $unsorted;
   for ($i=0; $i < sizeof($sorted)-1; $i++) {
     for ($j=0; $j<sizeof($sorted)-1-$i; $j++)
       if ($sorted[$j][$column] > $sorted[$j+1][$column]) {
         $tmp = $sorted[$j];
         $sorted[$j] = $sorted[$j+1];
         $sorted[$j+1] = $tmp;
     }
   }
   return $sorted;
}

$sorted=$ary_adps= columnSort($ary_adps, 'homepage');
Back to top


Post new topic   Reply to topic    Apache Forum Index -> Coding & Scripting Corner
Page 1 of 1