[WordPress] How to define a new locale for sorting data.
<?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 ); |
<?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