php - Change and display element from an array -


i have awstat file of lists country code , how many visits , hits:

# domain - pages - hits - bandwidth begin_domain 1 ua 245 245 970690  90 647 10311747  cn 27 27 106974  ru 25 26 99953  gb 12 82 1155179  fr 7 7 41230  kr 4 4 15848  de 4 15 211641  in 3 15 234340  ph 2 2 7924  lv 2 2 0  ro 2 2 13856  il 1 1 3962  dk 1 1 3962  vn 1 1 3962  nl 1 1 3962  lt 1 1 3962  ca 0 1 20264  end_domain 

i'm trying extract , displays countries nombre of pages per country, tried this:

preg_match("/begin_domain(.*)end_domain/is", $awstats, $matches); $country = $matches[0] ;  awstats_extract_country($country) ; 

which calls function awstats_extract_country($country) :

function awstats_extract_country($country) {        $country = explode("\n", $country) ;      unset($country[(count($country)-1)]) ;      unset($country[0]) ;      foreach ($country $key => $value)     $country[$key] = explode(" ", $value) ;       //print_array($sider);     $fields = array(          0 => "country" ,         1 => "pages" ,         2 => "hits" ,         3 => "bandwidth" ,     ) ;      echo '<div id="collapse_awstats_extract_sider" class="accordion-body collapse in">';         echo '<div class="accordion-inner">';             print_table($country, $fields);          echo '</div>';     echo '</div>'; } 

but displays me countries abbreviated in file there way can show them in names of countries, mean ua ==> ukraineand on here http://www.iso.org/iso/fr/french_country_names_and_code_elements.htm

much appreciated

afaik there's no built-in function converts 2 letter country code country name, have make look-up table (using array or database), this question in stackoverflow


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -