You should not rely on this function to properly compare localized strings.
<?php
$a = "Österreich";
$b = "Oesterreich";
$z = "Zeta";
echo setlocale(LC_ALL, 0) . PHP_EOL; echo strcoll($a, $b) . PHP_EOL; echo strcoll($b, $a) . PHP_EOL; echo strcoll($a, $z) . PHP_EOL; echo setlocale(LC_ALL, "de_DE") . PHP_EOL; echo strcoll($a, $b) . PHP_EOL; echo strcoll($b, $a) . PHP_EOL; echo strcoll($a, $z) . PHP_EOL; $collator = new Collator("de_DE");
echo $collator->compare($a, $b); echo $collator->compare($b, $a); echo $collator->compare($a, $z); ?>
Using the Collator (from the intl module) you will get the expected result for e.g. sorting such that the string "Österreich" will rank higher than "Zeta", but after "Oesterreich".
strcoll's output will differ per platform, locale and used c library, while the Collator will give more stable results on different platforms.