[thelist] PHP syntax - output of two variables in a string
Paul Waring
paul at xk7.net
Mon Jun 25 11:23:09 CDT 2007
On Mon, Jun 25, 2007 at 10:08:55AM -0600, Bob Meetin wrote:
> How do I set/escape a variable so that as the count increments, it
> outputs the value of the variable?
You would do this:
echo ${'abc' . $n};
This will perform the concatentation first, then interpolate it as a
variable name.
Although personally I'd recommend using an array rather than lots of
variables, like so:
$abc = array('abc', 'apples', 'pumpkins');
echo $abc[$n];
As this is *much* clearer (in mu opinion).
Paul
More information about the thelist
mailing list