-
-
Save tommcfarlin/42432c1840d29d9fb3c2 to your computer and use it in GitHub Desktop.
[WordPress] How to define a new locale for sorting data.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Set a new locale, define string comparison functions to be affected, | |
// and store the original locale. | |
$original_locale = setlocale( LC_COLLATE, 'de_DE' ); | |
// Do whatever you need to do for German sorting here | |
// Reset the locale to its original state | |
setlocale( LC_COLLATE, $original_locale ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Instantiate the Collator and pass it the locale | |
$col = new \Collator( 'de_DE' ); | |
// Sort the array of last names. | |
$col->asort( $last_names ) | |
// Done! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment