wemustdesign Posted April 4, 2009 Share Posted April 4, 2009 I am creating a php directory from scratch. I am starting the directory with UK business's and then american business's. I am not sure how to approach creating a multi region directory, is it possible to get php to tell which area the user is from and thus only display the directory that is specific to there location? Link to comment https://forums.phpfreaks.com/topic/152527-how-to-approach-this/ Share on other sites More sharing options...
Fruct0se Posted April 4, 2009 Share Posted April 4, 2009 While it is not always possible to get the users country here are a couple functions that will attempt to get the users language and country. You can call this by using: $anyvar = get_language(); The value of $anyvar will be the detected language and/or country retreived from the user. Good luck. <?php function get_languages() { // get the languages $a_languages = languages(); $accepted = explode(",", $_SERVER['HTTP_ACCEPT_LANGUAGE']); for ($i = 0; $i < count($accepted); $i++) { if ($a_languages[$accepted[$i]]) { return $a_languages[$accepted[$i]]; } } } function languages() { // pack abbreviation/language array // important note: you must have the default language as the last item in each major language, after all the // en-ca type entries, so en would be last in that case $a_languages = array('af' => 'Afrikaans', 'sq' => 'Albanian', 'ar-dz' => 'Arabic (Algeria)', 'ar-bh' => 'Arabic (Bahrain)', 'ar-eg' => 'Arabic (Egypt)', 'ar-iq' => 'Arabic (Iraq)', 'ar-jo' => 'Arabic (Jordan)', 'ar-kw' => 'Arabic (Kuwait)', 'ar-lb' => 'Arabic (Lebanon)', 'ar-ly' => 'Arabic (libya)', 'ar-ma' => 'Arabic (Morocco)', 'ar-om' => 'Arabic (Oman)', 'ar-qa' => 'Arabic (Qatar)', 'ar-sa' => 'Arabic (Saudi Arabia)', 'ar-sy' => 'Arabic (Syria)', 'ar-tn' => 'Arabic (Tunisia)', 'ar-ae' => 'Arabic (U.A.E.)', 'ar-ye' => 'Arabic (Yemen)', 'ar' => 'Arabic', 'hy' => 'Armenian', 'as' => 'Assamese', 'az' => 'Azeri', 'eu' => 'Basque', 'be' => 'Belarusian', 'bn' => 'Bengali', 'bg' => 'Bulgarian', 'ca' => 'Catalan', 'zh-cn' => 'Chinese (China)', 'zh-hk' => 'Chinese (Hong Kong SAR)', 'zh-mo' => 'Chinese (Macau SAR)', 'zh-sg' => 'Chinese (Singapore)', 'zh-tw' => 'Chinese (Taiwan)', 'zh' => 'Chinese', 'hr' => 'Croatian', 'cs' => 'Czech', 'da' => 'Danish', 'div' => 'Divehi', 'nl-be' => 'Dutch (Belgium)', 'nl' => 'Dutch (Netherlands)', 'en-au' => 'English (Australia)', 'en-bz' => 'English (Belize)', 'en-ca' => 'English (Canada)', 'en-ie' => 'English (Ireland)', 'en-jm' => 'English (Jamaica)', 'en-nz' => 'English (New Zealand)', 'en-ph' => 'English (Philippines)', 'en-za' => 'English (South Africa)', 'en-tt' => 'English (Trinidad)', 'en-gb' => 'English (United Kingdom)', 'en-us' => 'English (United States)', 'en-zw' => 'English (Zimbabwe)', 'en' => 'English', 'us' => 'English (United States)', 'et' => 'Estonian', 'fo' => 'Faeroese', 'fa' => 'Farsi', 'fi' => 'Finnish', 'fr-be' => 'French (Belgium)', 'fr-ca' => 'French (Canada)', 'fr-lu' => 'French (Luxembourg)', 'fr-mc' => 'French (Monaco)', 'fr-ch' => 'French (Switzerland)', 'fr' => 'French (France)', 'mk' => 'FYRO Macedonian', 'gd' => 'Gaelic', 'ka' => 'Georgian', 'de-at' => 'German (Austria)', 'de-li' => 'German (Liechtenstein)', 'de-lu' => 'German (Luxembourg)', 'de-ch' => 'German (Switzerland)', 'de' => 'German (Germany)', 'el' => 'Greek', 'gu' => 'Gujarati', 'he' => 'Hebrew', 'hi' => 'Hindi', 'hu' => 'Hungarian', 'is' => 'Icelandic', 'id' => 'Indonesian', 'it-ch' => 'Italian (Switzerland)', 'it' => 'Italian (Italy)', 'ja' => 'Japanese', 'kn' => 'Kannada', 'kk' => 'Kazakh', 'kok' => 'Konkani', 'ko' => 'Korean', 'kz' => 'Kyrgyz', 'lv' => 'Latvian', 'lt' => 'Lithuanian', 'ms' => 'Malay', 'ml' => 'Malayalam', 'mt' => 'Maltese', 'mr' => 'Marathi', 'mn' => 'Mongolian (Cyrillic)', 'ne' => 'Nepali (India)', 'nb-no' => 'Norwegian (Bokmal)', 'nn-no' => 'Norwegian (Nynorsk)', 'no' => 'Norwegian (Bokmal)', 'or' => 'Oriya', 'pl' => 'Polish', 'pt-br' => 'Portuguese (Brazil)', 'pt' => 'Portuguese (Portugal)', 'pa' => 'Punjabi', 'rm' => 'Rhaeto-Romanic', 'ro-md' => 'Romanian (Moldova)', 'ro' => 'Romanian', 'ru-md' => 'Russian (Moldova)', 'ru' => 'Russian', 'sa' => 'Sanskrit', 'sr' => 'Serbian', 'sk' => 'Slovak', 'ls' => 'Slovenian', 'sb' => 'Sorbian', 'es-ar' => 'Spanish (Argentina)', 'es-bo' => 'Spanish (Bolivia)', 'es-cl' => 'Spanish (Chile)', 'es-co' => 'Spanish (Colombia)', 'es-cr' => 'Spanish (Costa Rica)', 'es-do' => 'Spanish (Dominican Republic)', 'es-ec' => 'Spanish (Ecuador)', 'es-sv' => 'Spanish (El Salvador)', 'es-gt' => 'Spanish (Guatemala)', 'es-hn' => 'Spanish (Honduras)', 'es-mx' => 'Spanish (Mexico)', 'es-ni' => 'Spanish (Nicaragua)', 'es-pa' => 'Spanish (Panama)', 'es-py' => 'Spanish (Paraguay)', 'es-pe' => 'Spanish (Peru)', 'es-pr' => 'Spanish (Puerto Rico)', 'es-us' => 'Spanish (United States)', 'es-uy' => 'Spanish (Uruguay)', 'es-ve' => 'Spanish (Venezuela)', 'es' => 'Spanish (Traditional Sort)', 'sx' => 'Sutu', 'sw' => 'Swahili', 'sv-fi' => 'Swedish (Finland)', 'sv' => 'Swedish', 'syr' => 'Syriac', 'ta' => 'Tamil', 'tt' => 'Tatar', 'te' => 'Telugu', 'th' => 'Thai', 'ts' => 'Tsonga', 'tn' => 'Tswana', 'tr' => 'Turkish', 'uk' => 'Ukrainian', 'ur' => 'Urdu', 'uz' => 'Uzbek', 'vi' => 'Vietnamese', 'xh' => 'Xhosa', 'yi' => 'Yiddish', 'zu' => 'Zulu'); return $a_languages; } ?> Link to comment https://forums.phpfreaks.com/topic/152527-how-to-approach-this/#findComment-801114 Share on other sites More sharing options...
wemustdesign Posted April 4, 2009 Author Share Posted April 4, 2009 Thanks for the reply will try this out now! Link to comment https://forums.phpfreaks.com/topic/152527-how-to-approach-this/#findComment-801276 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.