[thelist] PHP syntax - output of two variables in a string

Bob Meetin ontheroad at frii.com
Mon Jun 25 11:08:55 CDT 2007


Having some trouble with a loop, seems simple enough, but... The loop is 
incrementing fine, it's my misunderstanding of how to escape or set the 
variables correctly.

$abc = "abc";
$abc1 = "apples";
$abc2 = "pumpkins";

When:
$n = 1;
$output = "$abc$n";
echo "Output: $output<br>";

How do I set/escape a variable so that as the count increments, it 
outputs the value of the variable?
I have tried curly brackets, backslash, double $$, etc.  As output I end 
up with things like:

Output: abc1
Output: $abc1

The output should be:

Output: apples

-Bob







More information about the thelist mailing list