Reply to Re: eval()

Your name:

Reply:


Posted by rog on 02/27/07 00:47

Thanks,

It looks like it's all about the {} operator or whatever it is.
Wish they were covered in the php docs.

:)
R



"Norman Peelman" <npeelman@cfl.rr.com> wrote in message
news:45e37722$0$24693$4c368faf@roadrunner.com...
> rog wrote:
>> I have some variables, $unit1, $unit2 and $unit3, that I would like to
>> read from a loop like this (or any other way):
>>
>> for($x=1;$x<=3;$x++)
>> {
>> $str='unit' . $x
>> echo eval($str);
>> }
>>
>> The debugger shows $str as '$unit1' but eval() gives a parse error.
>> Can someone give a tip?
>>
>> Thanks,
>> Roger
>>
>>
> for($x=1;$x<=3;$x++)
> { // create variabls unit1, unit2, unit3...
> ${"unit$x"} = $x;
> $str = "unit$x = ".${"unit$x"}.'<br>';
> //echo "unit$x = ${"unit$x"}<br>"; // will work too...
> }
> echo $unit2;
>
>
> output:
>
> unit1 = 1
> unit2 = 2
> unit3 = 3
> 2
>
> Norm

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация