note 99795 deleted from function.sort by danbrown

From: Date: Tue, 07 Sep 2010 14:43:51 +0000
Subject: note 99795 deleted from function.sort by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-172358@lists.php.net to get a copy of this message
Note Submitter: ricardosismeiro at yahoo dot co dot uk ---- <?php function sort_by($array,$field,$desc='desc'){ $index = array(); $result = array(); foreach($array as $k=>$row){ $index[] = $row[$field];} if ('desc' == $desc){ arsort($index); } else { asort($index);} foreach($index as $k=>$value){ $result[] = $array[$k]; unset($array[$k]); } return $result; } ?>

« previous php.notes (#172358) next »