Henk de Wit Posted May 18, 2012 Share Posted May 18, 2012 I’m using a multilanguage script to change from lanquage. Now I’m having troubles to change from a language when I’m at the default language (English) The site looks like: example.com ( Main directory) example.com/fr/ example.com/es/ When I’m at example.com/fr/blabla/index and I want to go to example.com/es/blabla/index it works fine. But when I’m at example.com/blabla/index and I want to go to example.com/fr/blabla/index . I’m redirect to example.com/fr/index I’m using: <?php function switchLanguage($lang) { $u = explode('/', $_SERVER['REQUEST_URI']); $u[1] = $lang; return implode('/', $u); } ?> So it’s logic that I’m not redirect to the correct path because there is no directory /eng. I was thinking is it possible to rewrite the url using a array? Something like this: <?php function switchLanguage($lang) $array1 = array(' ', $_SERVER['REQUEST_URI']); $array2 = array('$lang', ' '); $newArray = array_combine($array1, $array2); foreach ($newArray as $key ) { echo "$key $value"; } ?> But how can I get the value in a url or where Am I going wrong. To use a database or .ini and geoip caching is not an option Quote Link to comment https://forums.phpfreaks.com/topic/262723-multilanguage-problem-solving-with-an-arry/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.