On Wed, 5 Aug 2009 16:17:26 -0600, Govinda wrote:

> I want to do this:
> (I am just assuming it won't work; I haven't even tried it yet)
> 
> $var1='apple';
> $Fruit_$var1="organic";
> echo "$Fruit_apple"; // I want this to return "organic"
> 
> Or how are you guys dynamically naming PHP vars on the fly?

Others have mentioned variable variables. While I have
used those, I tend to prefer arrays:

  $var1 = 'apple';
  $fruits[$var1] = 'organic';
  echo $fruits[$var1];


/Nisse

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to