note 38957 deleted from function.array-multisort by aidan

From: Date: Sun, 03 Oct 2004 10:39:20 +0000
Subject: note 38957 deleted from function.array-multisort by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-77791@lists.php.net to get a copy of this message
Note Submitter: marin at xit dot nl ---- I needed a function to sort multi dimensional arrays, but case in-sensitive. I used Ichier function with a little modification: <?php function array_csort() { //coded by Ichier2003 $args = func_get_args(); $marray = array_shift($args); $msortline = "return(array_multisort("; foreach ($args as $arg) { $i++; if (is_string($arg)) { foreach ($marray as $row) { // added by Marin for case in-sensitive search $a = strtoupper($row[$arg]); $sortarr[$i][] = $a; } } else { $sortarr[$i] = $arg; } $msortline .= "\$sortarr[".$i."],"; } $msortline .= "\$marray));"; eval($msortline); return $marray; } ?> For usage of this function, see Ichier's post somewhere below Thanks Ichier, a superb function indeed!

« previous php.notes (#77791) next »