note 92122 added to function.asort

From: Date: Thu, 09 Jul 2009 20:30:29 +0000
Subject: note 92122 added to function.asort
Groups: php.notes 
Request: Send a blank email to php-notes+get-158123@lists.php.net to get a copy of this message
// Sort an associative array while case insensitive // Might be useful to someone else // // Example: // $arr = $res1 = array( // [a] => Trans Union // [b] => TRACE // [c] => TeleMatch // [d] => test); // // asort($res1); // $res2 = asorti($arr); // // ASORT RESULT // $res1 = array( // [b] => TRACE // [c] => TeleMatch // [a] => Trans Union // [d] => test); // // DESIRED RESULT // $res2 = array( // [c] => TeleMatch // [d] => test // [b] => TRACE // [a] => Trans Union); function asorti($arr) { $arr2 = $arr; foreach($arr2 as $key => $val) { $arr2[$key] = strtolower($val); } asort($arr2); foreach($arr2 as $key => $val) { $arr2[$key] = $arr[$key]; } return $arr2; } ---- Server IP: 69.147.83.197 Probable Submitter: 64.79.235.222 ---- Manual Page -- http://www.php.net/manual/en/function.asort.php Edit -- https://master.php.net/note/edit/92122 Del: integrated -- https://master.php.net/note/delete/92122/integrated Del: useless -- https://master.php.net/note/delete/92122/useless Del: bad code -- https://master.php.net/note/delete/92122/bad+code Del: spam -- https://master.php.net/note/delete/92122/spam Del: non-english -- https://master.php.net/note/delete/92122/non-english Del: in docs -- https://master.php.net/note/delete/92122/in+docs Del: other reasons-- https://master.php.net/note/delete/92122 Reject -- https://master.php.net/note/reject/92122 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#158123) next »