Page 1 of 1

Using STRING as an array

Posted: Thu May 04, 2006 9:29 am
by mbaroz
Weirdan | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi There
I have saved a list of VarNames in  my database that are presented as strings  "SITE[name]" ....
I would like to use it and assign it as it was a variable.

Code: Select all

<?php
$SITE[name]="value";
?>
i used the ${$DBVARNAME}="value";
but no success

Please help

Thanks
Moshe Bar-oz


Weirdan | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Thu May 04, 2006 9:42 am
by feyd
You'll have to break apart the name so you can get the actual variable name, "SITE," and the index inside of it, "name," and them create the variable like so:

Code: Select all

${$varName}[$index] = $value;