Re: dynamically naming PHP vars on the fly?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



u can "dynamical" chosse a variable name with a variable using a "douple" $
charachter eg.

$a = "this is a":
$b = "a";

echo $$b; outputs "this is a"

this is an all open feature to u

have fun
ralph

"Govinda" <govinda.webdnatalk@xxxxxxxxx> wrote in message
news:A215E849-2602-4CB3-9DA7-718FF047A187@xxxxxxxxxxxx
> HI all
>
> One thing I have been working around but now would love to just do it
> finally (and save workaround/longer code hassle) is when:
>
> I need to be able to create a variable (name it, and assign it a
> value) whose name is built up from a fixed string concatenated with
> another string which comes from the  value of another (already set)
> variable.
>
> Ie:
>
> 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?
>
> ------------
> John Butler (Govinda)
> govinda.webdnatalk@xxxxxxxxx
>
>
>



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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux