note 53893 deleted from function.usort by danbrown
| From: | danbrown@php.net | Date: | Sun, 23 Jan 2011 16:28:45 +0000 |
| Subject: | note 53893 deleted from function.usort by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-176075@lists.php.net to get a copy of this message | ||
Note Submitter:
----
Case insensitive sort with foreign letters.
<?php
$orig[] = "Abba";
$orig[] = "pappa";
$orig[] = "öiorhkl";
$orig[] = "öäåÖÄÅ1";
$orig[] = "ÖäåÖÄÅ1";
function cmp($a, $b)
{
$a=html_entity_decode(strtolower(htmlentities($a)));
$b=html_entity_decode(strtolower(htmlentities($b)));
if ( $a == $b ) {
return 0;
}
return ($a < $b) ? -1 : 1;
}
usort($orig,"cmp");
/*
returns:
Array
(
[0] => Abba
[1] => pappa
[2] => öiorhkl
[3] => ÖäåÖÄÅ1
[4] => öäåÖÄÅ1
)
*/
?>