-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcountry_list_array.inc.php
58 lines (47 loc) · 1.23 KB
/
country_list_array.inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?
// fix the path so that it also works when importing
$COUNTRY_ISO_CODES_FILE = dirname(__FILE__) . "/country-list-iso-codes_cz.txt";
function get_county_list_array()
{
global $COUNTRY_ISO_CODES_FILE;
$file = fopen($COUNTRY_ISO_CODES_FILE, 'r');
$data = fread($file, filesize($COUNTRY_ISO_CODES_FILE));
fclose($file);
$data = explode("\n", $data);
foreach($data as $row)
{
// list($cd,$nm) = explode(':',$row);
// $data2[$cd] = $nm;
$data2[] = explode(':', trim($row)); // also trim whitespaces
}
return $data2;
}
function generate_combobox_data($selected)
{
$dta = get_county_list_array();
$text = '';
foreach($dta as $row)
{
$text .= '<option value="'.$row[0].'"';
if ($selected == $row[0])
$text .= ' selected';
$text .= '>'.$row[1];
$text .= '</option>';
}
return $text;
}
function get_country_string($code)
{
global $COUNTRY_ISO_CODES_FILE;
$file = fopen($COUNTRY_ISO_CODES_FILE, 'r');
$data = fread($file, filesize($COUNTRY_ISO_CODES_FILE));
fclose($file);
$data = explode("\n", $data);
foreach($data as $row)
{
$data2 = explode(':', trim($row)); // also trim whitespaces
if ($data2[0] == $code) return $data2[1];
}
return '';
}
?>