note 74618 added to function.array-multisort

From: Date: Fri, 20 Apr 2007 11:01:21 +0000
Subject: note 74618 added to function.array-multisort
Groups: php.notes 
Request: Send a blank email to php-notes+get-125611@lists.php.net to get a copy of this message
<?php function array_sort_by_key($array, $sort_key, $order = SORT_ASC) { if($order != SORT_ASC && $order != SORT_DESC) return false; $keys = array_keys($array); $place = array_search($sort_key, $keys); foreach($array as $key => $row) { $sortingParameter[$key] = $row[$sort_key]; if($place == 0) { $theRest[$key] = array_slice($row, 1, count($row)); } else if($place == count($row) + 1) { $theRest[$key] = array_slice($row, 0, count($row) - 1); } else { $left = array_slice($row, 0, $place); $right = array_slice($row, $place + 1, count($row) - $place); $theRest[$key] = array_merge($left, $right); } } array_multisort($sortingParameter, $order, $theRest, $array); return $array; } ?> ---- Server IP: 195.184.96.15 Probable Submitter: 83.92.232.118 ---- Manual Page -- http://www.php.net/manual/en/function.array-multisort.php Edit -- https://master.php.net/note/edit/74618 Del: integrated -- https://master.php.net/note/delete/74618/integrated Del: useless -- https://master.php.net/note/delete/74618/useless Del: bad code -- https://master.php.net/note/delete/74618/bad+code Del: spam -- https://master.php.net/note/delete/74618/spam Del: non-english -- https://master.php.net/note/delete/74618/non-english Del: in docs -- https://master.php.net/note/delete/74618/in+docs Del: other reasons-- https://master.php.net/note/delete/74618 Reject -- https://master.php.net/note/reject/74618 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#125611) next »