note 33499 deleted from function.print-r by aidan

From: Date: Mon, 11 Oct 2004 13:06:24 +0000
Subject: note 33499 deleted from function.print-r by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-78335@lists.php.net to get a copy of this message
Note Submitter: chris dot meyer at knowledgenet dot com ---- If you have a multi_dimensional array and you want a case-insensitive sort, use the combination of fucntions below... I am sure there is a way you could write this all in one function, but I am lazy right now (its friday). $str_col_tosort = 2; $milti_dim_array = addLowerCaseElem($milti_dim_array,$str_col_tosort ); $milti_dim_array= array_csort($milti_dim_array,'sortonme'); function addLowerCaseElem($data_array, $col_tosort){ $i = 1; foreach($data_array as $data){ $data_array[$i]['sortonme'] = strtolower(print_r($data_array[$i][$col_tosort],true)); $i++; } return $data_array; } function array_csort($marray, $column) { //coded by Ichier2003 foreach ($marray as $row) { $sortarr[] = $row[$column]; } array_multisort($sortarr, $marray); return $marray; }

« previous php.notes (#78335) next »