\s*(?P[^><]*)\s*(?P[^><]*)\s*(?P[^><]*)\s*!i', $html, $list, PREG_SET_ORDER); $countries = array(); setlocale('LC_CTYPE', 'en_US'); foreach ($list as $row) { $code = strtoupper($row['code']); $name = utf8_decode($row['english']); $name = preg_replace('!(\s){2,}!', '\\1', $name); $name = ucwords(strtolower($name)); $countries[$code] = utf8_encode($name); } asort($countries, SORT_LOCALE_STRING); $out = ""; file_put_contents('countries_en.php', $out); $countries = array(); setlocale('LC_CTYPE', 'fr_FR'); foreach ($list as $row) { $code = strtoupper($row['code']); $name = utf8_decode($row['french']); $name = preg_replace('!(\s){2,}!', '\\1', $name); $name = ucwords(strtolower($name)); $countries[$code] = utf8_encode($name); } asort($countries, SORT_LOCALE_STRING); $out = ""; file_put_contents('countries_fr.php', $out); return true; } create_cc_lists(); ?>