note 37200 added to function.natcasesort
| From: | php at method5 dot de | Date: | Thu, 06 Nov 2003 15:56:56 +0000 |
| Subject: | note 37200 added to function.natcasesort | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-60003@lists.php.net to get a copy of this message | ||
hi all,
this is my first post at php.net first of all thank you for this huge site :)
ok i found it usefull to post this for others. in the german language we have words like 'ä ö
ü' its called "umlaute" and it was a problem to me to "naturally" sort an
huge array correctly so i coded this small block to get me helped, if anyone has an better idea
please post and let us know as i am not a real crack :)
1. change each "umlaut" (äöüß) into its "nearest" equivalent
2. natcasesorting it naturally
3. re-assiging the correct sorted array with the original-words again while keeping track of the
KEY...
example-array:
$aSupplier = array(3 => "MAN",2 => "Atlas",16 =>
"Chevrolet",17 => "Chrysler",19 => "Citroen",24 =>
"DAF",25 => "Daihatsu",27 => "Daewoo",28 =>
"Demag",30 => "Dodge",36 => "Schierling",208 =>
"HIAB",38 => "Hüffermann",39 => "Gergen",40 =>
"Kubato",41 => "Faun",43 => "Kleindienst",44 =>
"Swing",45 => "Neuhaus",46 => "Unimog",47 =>
"Meiller",48 => "Pfau-Johnston",49 => "Geesink",50 =>
"Schörling",51 => "Demag-Witting",53 => "Helmers",54 =>
"Ellermann",55 => "Jacobsen",56 => "Biki",57 =>
"Hansa",58 => "Kramer",59 => "Schmitz",60 =>
"Toro",61 => "Iseki",62 => "Haller",63 => "Kuka",64
=> "Brock",65 => "Ambross",66 => "Sobernheimer",67 =>
"Pietsch",68 => "Küpper",69 => "Weisser",71 =>
"Wackenhut");
foreach ( $aSupplier as $key => $value )
{
$aSupplier2[$key] = strtr($aSupplier[$key], "ÄÖÜäöüß", "AOUaous");
}
natcasesort($aSupplier2);
foreach ( $aSupplier2 as $key => $value )
{
if ( $aSupplier2[$key] != "" )
$aSupplier3[$key] = $aSupplier[$key];
}
echo "<pre>";
print_r($aSupplier3);
echo "</pre>";
greetz
tim
----
Manual Page -- http://www.php.net/manual/en/function.natcasesort.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+37200
Delete -- http://master.php.net/manage/user-notes.php?action=delete+37200&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+37200&report=yes
Search -- http://master.php.net/manage/user-notes.php