Jump to content


Help with arrays please

  • Please log in to reply
No replies to this topic

#1 scar5308

  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 23 October 2006 - 09:41 AM

I have been struggling with this problem for over a week and am not much nearer a solution. I am trying to create a multi language site that only requires the content to be added as simple text or html files although php files can be included. I have a page that detects the language used on the users browser; index.php:
class object {};
$config = new object;
$config->dir     = "/home/path/public_html/language2/lang_sets/";
if (! isset($lang)) {
	$lang = "pt";
	$lang = "en";
	$lang = "lv";
else if ($lang == "pt-br" ) { $SESSION["lang"] = "pt"; }
else if ($lang == "en" ) { $SESSION["lang"] = "en"; }
else if ($lang == "lv" ) { $SESSION["lang"] = "lv"; }
else { $SESSION["lang"] = "en"; }
$config->global = $config->dir.$lang."/language.php";
include ($config->global);
<title>webwhiz language2</title></head>

The page; language_sets/en/language.php, then includes the appropriate language specific content for my language files.
$content1 = include_once("../include/langselect.php");
$content2 = include_once("../include/contactform.php");
$content4 = include_once("../include/footer.php");
I then want the option to allow the visitor to select a different language to the one detected. For this I am trying to use this snippet I found. The included file above langselect.php contains the following code:

$language = $_GET["language"];


<select onchange="window.location='select.php?language='+this.value">


$language = array(






for ($i = 1; $i <= 4; $i++)


print "<option value=$i>$language[$i]</option>";

print "<h3>Language is : $language[$i]</h3>";




This provides a dropdown box to select a language. I am new to php and can't quite see how to make the above script redirect the user to a language specific page; in this case www.site.co.uk/language/index_en.php if English is selected from the dropdown.
Any help would be gratefully received!


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users