Sorting Language Code

Sorting Language Code

To sort Language Code Alphabetically.

Sort Values And to get main language wise and Ksort to sort using key value and also preserve the key value.

Use the Following Code

$language_list = array();
$lang = array();
//print_r("Before Sorting:");
    foreach($language_list as $value=>$key) {
        $lang_manuplate[$value] = explode('-', $value);
    $lang_sort = array();
    foreach ($lang_manuplate as $key => $value) {
    $lang_sort_1 = array();
    foreach ($lang_sort as $key => $value) {
        $lang_sort_1[$key] = $value;
    foreach ($lang_sort_1 as $key => $value) {
        foreach ($value as  $value) {
            $lang[$key][$value.'-'.$key] = $value.'-'.$key;

//print_r("After Sorting:");

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
  • Lazy-loading is enabled for both <img> and <iframe> tags. If you want certain elements skip lazy-loading, add no-b-lazy class name.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.