note 81155 added to function.asort

From: Date: Fri, 15 Feb 2008 22:34:59 +0000
Subject: note 81155 added to function.asort
Groups: php.notes 
Request: Send a blank email to php-notes+get-136187@lists.php.net to get a copy of this message
Dear mike at clear-link dot com! I needed a case insensitive version of your function. It is still not perfect as I have to do something with country specific characters (öüóőúéáűíÖÜÓŐÚÉÁŰÍ) function akisort(&$array,$valrev=false,$keyrev=false) { if ($valrev) { arsort($array); } else { asort($array); }; $vals = array_count_values($array); $i = 0; foreach ($vals AS $val=>$num) { $first = array_splice($array,0,$i); $tmp = array_splice($array,0,$num); $tmp2 = array(); foreach($tmp as $key => $value) { $tmp2[] = $key; $number = $value; }; natcasesort($tmp2); reset($tmp2); print_r($tmp2); unset($tmp); foreach($tmp2 as $key => $value) { $tmp[$value] = $number; }; if($keyrev) { $tmp = array_reverse($tmp, true); }; $array = array_merge($first,$tmp,$array); unset($tmp); $i = $i+$num; }; }; ---- Server IP: 195.56.193.17 Probable Submitter: 84.3.46.82 ---- Manual Page -- http://www.php.net/manual/en/function.asort.php Edit -- https://master.php.net/note/edit/81155 Del: integrated -- https://master.php.net/note/delete/81155/integrated Del: useless -- https://master.php.net/note/delete/81155/useless Del: bad code -- https://master.php.net/note/delete/81155/bad+code Del: spam -- https://master.php.net/note/delete/81155/spam Del: non-english -- https://master.php.net/note/delete/81155/non-english Del: in docs -- https://master.php.net/note/delete/81155/in+docs Del: other reasons-- https://master.php.net/note/delete/81155 Reject -- https://master.php.net/note/reject/81155 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#136187) next »