note 33499 added to function.print-r
| From: | chris at rack1 dot php dot net | Date: | Fri, 27 Jun 2003 20:09:10 +0000 |
| Subject: | note 33499 added to function.print-r | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-51111@lists.php.net to get a copy of this message | ||
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;
}
----
Manual Page -- http://www.php.net/manual/en/function.print-r.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33499
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33499&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33499&report=yes