Reply to Problem Evaluating Strings ...

Your name:

Reply:


Posted by number1.email on 12/11/05 18:17

I'm passing into a .php file the following:

I have an array called $q[], which has the contents:

$q[0] = 2
$q[1] = 4
$q[2] = 5
$q[3] = 3

Also, there are variables:
$quest1 = "First"
$quest2 = "Second"
$quest3 = "Third"
$quest4 = "Fourth"
$quest5 = "Fifth"

I'd like to be able to loop through this array (ie: $q[]) via a for
loop, and create the name of the other variables from the contents (ie:
$quest4 by concatenating "$quest" + $q[1] , $quest5 by concatenating
"$quest" + $q[2] , etc.). In addition, I'd like to be able to execute
these variables and echo the contents back to the screen (ie: for
$quest1...echo "First", for $quest2...echo "Second", etc.

When I try something like:

for($i = 0; $i < 4; $i++) {
echo $q[i];
echo eval("$q[i]");
echo eval("\$q[" . i . "]");

}

I get the "String" instead of the "Contents". How can I get "First",
"Second", etc. to echo onto the screen?

Thanks.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация