Gossamer Forum
Home : General : Perl Programming :

Variable Variables...

Quote Reply
Variable Variables...
Ok, so far I've had a good look at http://www.phpbuilder.com/columns/robert20000928.php3, but for some reason the code he is giving example of does not work :(

So far I have;

Code:
$gold = $gold_{$categoryis};
$gold_dis = $gold_dis_{$categoryis};

The idea being that $gold_* is changed to $gold_Local, or $gold_Regional, depending on what the category has set in it.

From what I can tell, the above should print the value of $gold_Regional when I have the $categoryis set to 'Regional' . Anyone got any ideas on why its not working? Frown

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [AndyNewby] Variable Variables... In reply to
Never mind, I got another way around it (longer and messier, but it works);

Code:
if ($categoryis == "Local") { $gold = $gold_Local; $gold_dis = $gold_Local_dis; }
if ($categoryis == "Regional") { $gold = $gold_Regional; $gold_dis = $gold_Regional_dis; }
if ($categoryis == "National") { $gold = $gold_National; $gold_dis = $gold_National_dis; }
if ($categoryis == "Sub") { $gold = $gold_Sub; $gold_dis = $gold_Sub_dis; }
if ($categoryis == "Main") { $gold = $gold_Main; $gold_dis = $gold_Main_dis; }

Wink

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!