PageRenderTime 36ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/environment/classes/CountryCodes.class.php

https://gitlab.com/x33n/ProjectPier-Core
PHP | 282 lines | 251 code | 6 blank | 25 comment | 0 complexity | 4602ff116e218ae5028230df42ac841f MD5 | raw file
  1. <?php
  2. /**
  3. * Class that lists all available countries at the moment with their codes and english names
  4. *
  5. * @version 1.0
  6. * @http://www.projectpier.org/
  7. */
  8. class CountryCodes {
  9. /**
  10. * Countries array
  11. *
  12. * @var array
  13. */
  14. static $countries = array(
  15. 'us' => 'United States',
  16. 'ca' => 'Canada',
  17. 'af' => 'Afghanistan',
  18. 'al' => 'Albania',
  19. 'dz' => 'Algeria',
  20. 'as' => 'American Samoa',
  21. 'ad' => 'Andorra',
  22. 'ao' => 'Angola',
  23. 'ai' => 'Anguilla',
  24. 'aq' => 'Antarctica',
  25. 'ag' => 'Antigua and Barbuda',
  26. 'ar' => 'Argentina',
  27. 'am' => 'Armenia',
  28. 'aw' => 'Aruba',
  29. 'au' => 'Australia',
  30. 'at' => 'Austria',
  31. 'az' => 'Azerbaijan',
  32. 'bs' => 'Bahamas',
  33. 'bh' => 'Bahrain',
  34. 'bd' => 'Bangladesh',
  35. 'bb' => 'Barbados',
  36. 'by' => 'Belarus',
  37. 'be' => 'Belgium',
  38. 'bz' => 'Belize',
  39. 'bj' => 'Benin',
  40. 'bm' => 'Bermuda',
  41. 'bt' => 'Bhutan',
  42. 'bo' => 'Bolivia',
  43. 'ba' => 'Bosnia and Herzegovina',
  44. 'bw' => 'Botswana',
  45. 'bv' => 'Bouvet Island',
  46. 'br' => 'Brazil',
  47. 'io' => 'British Indian Ocean Territory',
  48. 'vg' => 'British Virgin Islands',
  49. 'bn' => 'Brunei',
  50. 'bg' => 'Bulgaria',
  51. 'bf' => 'Burkina Faso',
  52. 'bi' => 'Burundi',
  53. 'kh' => 'Cambodia',
  54. 'cm' => 'Cameroon',
  55. 'cv' => 'Cape Verde',
  56. 'ky' => 'Cayman Islands',
  57. 'cf' => 'Central African Republic',
  58. 'td' => 'Chad',
  59. 'cl' => 'Chile',
  60. 'cn' => 'China',
  61. 'cx' => 'Christmas Island',
  62. 'cc' => 'Cocos Islands',
  63. 'co' => 'Colombia',
  64. 'km' => 'Comoros',
  65. 'cg' => 'Congo',
  66. 'ck' => 'Cook Islands',
  67. 'cr' => 'Costa Rica',
  68. 'hr' => 'Croatia',
  69. 'cu' => 'Cuba',
  70. 'cy' => 'Cyprus',
  71. 'cz' => 'Czech Republic',
  72. 'dk' => 'Denmark',
  73. 'dj' => 'Djibouti',
  74. 'dm' => 'Dominica',
  75. 'do' => 'Dominican Republic',
  76. 'tp' => 'East Timor',
  77. 'ec' => 'Ecuador',
  78. 'eg' => 'Egypt',
  79. 'sv' => 'El Salvador',
  80. 'gq' => 'Equatorial Guinea',
  81. 'er' => 'Eritrea',
  82. 'ee' => 'Estonia',
  83. 'et' => 'Ethiopia',
  84. 'fk' => 'Falkland Islands',
  85. 'fo' => 'Faroe Islands',
  86. 'fj' => 'Fiji',
  87. 'fi' => 'Finland',
  88. 'fr' => 'France',
  89. 'gf' => 'French Guiana',
  90. 'pf' => 'French Polynesia',
  91. 'tf' => 'French Southern Territories',
  92. 'ga' => 'Gabon',
  93. 'gm' => 'Gambia',
  94. 'ge' => 'Georgia',
  95. 'de' => 'Germany',
  96. 'gh' => 'Ghana',
  97. 'gi' => 'Gibraltar',
  98. 'gr' => 'Greece',
  99. 'gl' => 'Greenland',
  100. 'gd' => 'Grenada',
  101. 'gp' => 'Guadeloupe',
  102. 'gu' => 'Guam',
  103. 'gt' => 'Guatemala',
  104. 'gn' => 'Guinea',
  105. 'gw' => 'Guinea-Bissau',
  106. 'gy' => 'Guyana',
  107. 'ht' => 'Haiti',
  108. 'hm' => 'Heard and McDonald Islands',
  109. 'hn' => 'Honduras',
  110. 'hk' => 'Hong Kong',
  111. 'hu' => 'Hungary',
  112. 'is' => 'Iceland',
  113. 'in' => 'India',
  114. 'id' => 'Indonesia',
  115. 'ir' => 'Iran',
  116. 'iq' => 'Iraq',
  117. 'ie' => 'Ireland',
  118. 'il' => 'Israel',
  119. 'it' => 'Italy',
  120. 'ci' => 'Ivory Coast',
  121. 'jm' => 'Jamaica',
  122. 'jp' => 'Japan',
  123. 'jo' => 'Jordan',
  124. 'kz' => 'Kazakhstan',
  125. 'ke' => 'Kenya',
  126. 'ki' => 'Kiribati',
  127. 'kp' => 'North Korea',
  128. 'kr' => 'South Korea',
  129. 'kw' => 'Kuwait',
  130. 'kg' => 'Kyrgyzstan',
  131. 'la' => 'Laos',
  132. 'lv' => 'Latvia',
  133. 'lb' => 'Lebanon',
  134. 'ls' => 'Lesotho',
  135. 'lr' => 'Liberia',
  136. 'ly' => 'Libya',
  137. 'li' => 'Liechtenstein',
  138. 'lt' => 'Lithuania',
  139. 'lu' => 'Luxembourg',
  140. 'mo' => 'Macau',
  141. 'mk' => 'Macedonia',
  142. 'mg' => 'Madagascar',
  143. 'mw' => 'Malawi',
  144. 'my' => 'Malaysia',
  145. 'mv' => 'Maldives',
  146. 'ml' => 'Mali',
  147. 'mt' => 'Malta',
  148. 'mh' => 'Marshall Islands',
  149. 'mq' => 'Martinique',
  150. 'mr' => 'Mauritania',
  151. 'mu' => 'Mauritius',
  152. 'yt' => 'Mayotte',
  153. 'mx' => 'Mexico',
  154. 'fm' => 'Micronesia',
  155. 'md' => 'Moldova',
  156. 'mc' => 'Monaco',
  157. 'mn' => 'Mongolia',
  158. 'me' => 'Montenegro',
  159. 'ms' => 'Montserrat',
  160. 'ma' => 'Morocco',
  161. 'mz' => 'Mozambique',
  162. 'mm' => 'Myanmar',
  163. 'na' => 'Namibia',
  164. 'nr' => 'Nauru',
  165. 'np' => 'Nepal',
  166. 'nl' => 'Netherlands',
  167. 'an' => 'Netherlands Antilles',
  168. 'nc' => 'New Caledonia',
  169. 'nz' => 'New Zealand',
  170. 'ni' => 'Nicaragua',
  171. 'ne' => 'Niger',
  172. 'ng' => 'Nigeria',
  173. 'nu' => 'Niue',
  174. 'nf' => 'Norfolk Island',
  175. 'mp' => 'Northern Mariana Islands',
  176. 'no' => 'Norway',
  177. 'om' => 'Oman',
  178. 'pk' => 'Pakistan',
  179. 'pw' => 'Palau',
  180. 'pa' => 'Panama',
  181. 'pg' => 'Papua New Guinea',
  182. 'py' => 'Paraguay',
  183. 'pe' => 'Peru',
  184. 'ph' => 'Philippines',
  185. 'pn' => 'Pitcairn Island',
  186. 'pl' => 'Poland',
  187. 'pt' => 'Portugal',
  188. 'pr' => 'Puerto Rico',
  189. 'qa' => 'Qatar',
  190. 're' => 'Reunion',
  191. 'ro' => 'Romania',
  192. 'ru' => 'Russia',
  193. 'rw' => 'Rwanda',
  194. 'gs' => 'S. Georgia and S. Sandwich Isls.',
  195. 'kn' => 'Saint Kitts & Nevis',
  196. 'lc' => 'Saint Lucia',
  197. 'vc' => 'Saint Vincent and The Grenadines',
  198. 'ws' => 'Samoa',
  199. 'sm' => 'San Marino',
  200. 'st' => 'Sao Tome and Principe',
  201. 'sa' => 'Saudi Arabia',
  202. 'sn' => 'Senegal',
  203. 'rs' => 'Serbia',
  204. 'sc' => 'Seychelles',
  205. 'sl' => 'Sierra Leone',
  206. 'sg' => 'Singapore',
  207. 'sk' => 'Slovakia',
  208. 'si' => 'Slovenia',
  209. 'sp' => 'Solomon Islands',
  210. 'so' => 'Somalia',
  211. 'za' => 'South Africa',
  212. 'es' => 'Spain',
  213. 'lk' => 'Sri Lanka',
  214. 'sh' => 'St. Helena',
  215. 'pm' => 'St. Pierre and Miquelon',
  216. 'sd' => 'Sudan',
  217. 'sr' => 'Suriname',
  218. 'sj' => 'Svalbard and Jan Mayen Islands',
  219. 'sz' => 'Swaziland',
  220. 'se' => 'Sweden',
  221. 'ch' => 'Switzerland',
  222. 'sy' => 'Syria',
  223. 'tw' => 'Taiwan',
  224. 'tj' => 'Tajikistan',
  225. 'tz' => 'Tanzania',
  226. 'th' => 'Thailand',
  227. 'tg' => 'Togo',
  228. 'tk' => 'Tokelau',
  229. 'to' => 'Tonga',
  230. 'tt' => 'Trinidad and Tobago',
  231. 'tn' => 'Tunisia',
  232. 'tr' => 'Turkey',
  233. 'tm' => 'Turkmenistan',
  234. 'tc' => 'Turks and Caicos Islands',
  235. 'tv' => 'Tuvalu',
  236. 'um' => 'U.S. Minor Outlying Islands',
  237. 'ug' => 'Uganda',
  238. 'ua' => 'Ukraine',
  239. 'ae' => 'United Arab Emirates',
  240. 'uk' => 'United Kingdom',
  241. 'uy' => 'Uruguay',
  242. 'uz' => 'Uzbekistan',
  243. 'vu' => 'Vanuatu',
  244. 'va' => 'Vatican City',
  245. 've' => 'Venezuela',
  246. 'vn' => 'Vietnam',
  247. 'vi' => 'Virgin Islands',
  248. 'wf' => 'Wallis and Futuna Islands',
  249. 'eh' => 'Western Sahara',
  250. 'ye' => 'Yemen',
  251. 'zr' => 'Zaire',
  252. 'zm' => 'Zambia',
  253. 'zw' => 'Zimbabwe'
  254. ); // array
  255. /**
  256. * Return array of countries
  257. *
  258. * @access public
  259. * @param void
  260. * @return array
  261. */
  262. function getAll() {
  263. return self::$countries;
  264. } // getAll
  265. /**
  266. * Find specific country by country code
  267. *
  268. * @access public
  269. * @param string $code
  270. * @return string
  271. */
  272. function getCountryNameByCode($code) {
  273. return array_var(self::$countries, $code);
  274. } // getCountryNameByCode
  275. } // CountryCodes
  276. ?>