Jump to content

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


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>'; 

		}

?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.