Using a concatenated $ to refer to an existing $
Posted: Fri Nov 25, 2011 8:44 pm
Hi. I still learning and have 'duh' problem. I want a combination of $'s $like$this[$combination] to act like a $ name. I've tried every way I can research.
Example:
Gives
and not A juicy red apple.
I even tried things like $show = ${'$desc_' . $fruits[$apple]}; and with no luck. I'm sure I'm being dense, but I don't get it. Help please?
Example:
Code: Select all
$desc_apple = "A juicy red apple"; $desc_pear = "A sweet tasting pear.";
// ....
$show = '$desc_' . "$fruits[$this]"; // $desc_ is the fixed prefix and not the variable so I put it in single quotes.
echo $show;
Code: Select all
$desc_appleI even tried things like $show = ${'$desc_' . $fruits[$apple]}; and with no luck. I'm sure I'm being dense, but I don't get it. Help please?