note 93462 added to function.sort

From: Date: Fri, 11 Sep 2009 01:41:27 +0000
Subject: note 93462 added to function.sort
Groups: php.notes 
Request: Send a blank email to php-notes+get-160440@lists.php.net to get a copy of this message
In response to the comment by "danm68" about sorting strings alphabetically, I created a user-defined sorting function which compares lowercase strings: <?php function sortAlphabeticallyIgnoreCase($a, $b) { if ($a == $b) { return 0; } return (strtolower($a) < strtolower($b)) ? -1 : 1; } usort($myExampleArray, 'sortAlphabeticallyIgnoreCase'); ?> There may be a similar solution out there already (though I couldn't see one). ---- Server IP: 209.41.74.194 Probable Submitter: 165.228.143.194 ---- Manual Page -- http://www.php.net/manual/en/function.sort.php Edit -- https://master.php.net/note/edit/93462 Del: integrated -- https://master.php.net/note/delete/93462/integrated Del: useless -- https://master.php.net/note/delete/93462/useless Del: bad code -- https://master.php.net/note/delete/93462/bad+code Del: spam -- https://master.php.net/note/delete/93462/spam Del: non-english -- https://master.php.net/note/delete/93462/non-english Del: in docs -- https://master.php.net/note/delete/93462/in+docs Del: other reasons-- https://master.php.net/note/delete/93462 Reject -- https://master.php.net/note/reject/93462 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#160440) next »