Re: variable variables and eval
| From: | Richard Lynch | Date: | Tue, 14 Aug 2001 00:07:06 +0000 |
| Subject: | Re: variable variables and eval | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-62530@lists.php.net to get a copy of this message | ||
> i have come across a strange problem with variable variables. Basicly i'm
> doing the following and its not working:
>
> $section = 'data["SITE"][0]["NAME"][0]';
> $pData = 'My Site.';
> ${sprintf('$%s', $section)}.=$pData;
>
> but it is not working. But if i do this:
>
> eval('$'.$section.'.="'.addslashes($pData).'";');
>
> it works and all is well. I don't really want to use eval() and just
> wanted to see if anybody has any ideas why the above doesn't work.
Why is the sprintf in there?...
Try this:
${$section} .= $pData;
--
WARNING richard@zend.com address is an endangered species -- Use
ceo@l-i-e.com
Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm