Page 1 of 1
merging two variables for if() structure
Posted: Thu Sep 16, 2004 1:04 am
by nacho_c
How is possible to unite two variables for an if() structure?
for ($i = 1; $i <= 6; $i++)
{
if ($language_$i != ""){
print "bla bla bla";
}
of course this doesn´t work but it is what I mean..
Posted: Thu Sep 16, 2004 1:09 am
by feyd

[devnet]metaprogramming[/devnet]
although it's generally better to use arrays for your example...
Posted: Thu Sep 16, 2004 1:44 am
by nacho_c
Ok, but that is for printing..I don´t want to print the variables..
I want to compare them together against some value..
Could you explain how can I merge the values of this variables for this
for ($i = 1; $i <= 6; $i++)
{
if ($language_$i != "")
{
.......
}
}
Posted: Thu Sep 16, 2004 2:26 am
by feyd
read the topics found in my link more closely.
Posted: Thu Sep 16, 2004 4:52 am
by nacho_c
I still don´t get it..maybe I´m stupid but I don´t understand what you exactly mean..
Look, this is what I made and is not working..
for ($i = 1; $i <= 6; $i++)
{
$selected_language = ${'language_$i'};
if ($selected_language != "")
{
}
}
this is not working..please help me

Posted: Thu Sep 16, 2004 6:45 am
by nacho_c
YESSSSS!!
NOW I GOT IT!
HERE IS THE CODE FOR EVERYBODY!
The language and level variables come from a selection form.
In that form, instead of writing the same code 6 times to make 6 lists
there´s a loop which creates 6 the same lists with different name variable
which is name=\"language_$i\" So with this piece of code I can
process all forms at same time.
for ($i = 1; $i <= 6; $i++)
{
$selected_language = ${'language_'.$i};
if ($selected_language)
{
.....
}
}
Posted: Thu Sep 16, 2004 6:48 am
by dethron
plz change the topic by adding [SOLVED] string, so we can save time to read
