Hello im trying to do this: Im deep into strings right now and i have a line where i need to merge a string of text and a dynamic variable to produce the value of the 2 combined e.g i have a string of text "question" and i have a variable $number the number is in a loop so it increments so i could have question1 question2 question3 etc but what i want to do is have it display the value of question1 e.g "How do you spell red" and not echo "question1" any help would be greatly appreciated i have a feeling it has to do with brackets or parenthesis. Thanks, -Tim
You mean like... $question = ${'question' . $number}; PHP: ?? You're better off using arrays though...
Worked perfect, thank you for your time. rep added. yea i wish i used an array from the start uuuuugh lol.
Hey, Suppose you need to print from 1 to n questions, you can do: foreach(range(1,$n) as $num) { $question = $('question'.$num); } PHP: ~ Thomas
In your original program, if you use $$ (double), it will print what you require. e.g. echo $$question; it will print "How do you spell red"