note 97930 added to function.sort

From: Date: Sun, 16 May 2010 15:28:03 +0000
Subject: note 97930 added to function.sort
Groups: php.notes 
Request: Send a blank email to php-notes+get-169308@lists.php.net to get a copy of this message
@Dollar Hauler Admin: <?php public static function array_sortkey($array, $sort_by) { $args = func_get_args(); array_shift($args); array_shift($args); // sort by ? foreach ($array as $pos => $val) $tmp_array[$pos] = $val[$sort_by]; asort($tmp_array); // display however you want foreach ($tmp_array as $pos => $val) { $return_array[$pos][$sort_by] = $array[$pos][$sort_by]; foreach($args as $key) if(isset($array[$pos][$key])) { $return_array[$pos][$key] = $array[$pos][$key]; unset($array[$pos][$key]); } if(is_array($array[$pos])) foreach($array[$pos] as $key => $value) $return_array[$pos][$key] = $array[$pos][$key]; } return $return_array; } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 95.222.174.181 ---- Manual Page -- http://www.php.net/manual/en/function.sort.php Edit -- https://master.php.net/note/edit/97930 Del: integrated -- https://master.php.net/note/delete/97930/integrated Del: useless -- https://master.php.net/note/delete/97930/useless Del: bad code -- https://master.php.net/note/delete/97930/bad+code Del: spam -- https://master.php.net/note/delete/97930/spam Del: non-english -- https://master.php.net/note/delete/97930/non-english Del: in docs -- https://master.php.net/note/delete/97930/in+docs Del: other reasons-- https://master.php.net/note/delete/97930 Reject -- https://master.php.net/note/reject/97930 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#169308) next »