Jump to content

[SOLVED] Creating a DEFINED variable from anoter variable and text?


Vivid Lust

Recommended Posts

Hey all,

 

I have a language system and have decided to store a list of languages as follows:

 

<?php
//Languages
DEFINE('Lang1','Afrikaans');
DEFINE('Lang2','Akan');
DEFINE('Lang3','Albanian');
DEFINE('Lang4','Amharic (Ethiopian)');
DEFINE('Lang5','Arabic, Egyptian');
// etc etc
?>

 

And then im displaying them in a drop down box as:

 

<?php
for ( $counter = 1; $counter <= 130; $counter += 1) {
			echo '<option value="'.$counter.'" >';
			echo Lang.$counter;
			echo '</option>'; 

		}
?>

 

However PHP doesnt recognise what I put is a defined varibale and instead echos "Lang1", "Lang2" etc.

 

Any help?

 

Thanks

I now get this:

 

Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in /home/penpal/public_html/signup.php on line 18

 

Edited Code:

 

<?php
for ( $counter = 1; $counter <= 130; $counter += 1) {
			echo '<option value="'.$counter.'" >';
			echo Lang$counter;
			echo '</option>'; 

		}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.