You are here: Re: Evaluating Strings... « PHP Programming Language « IT news, forums, messages
Re: Evaluating Strings...

Posted by Oli Filth on 12/11/05 13:16

number1.email@gmail.com said the following on 11/12/2005 10:59:
> In php, I have an array called "q". The elements are:
>
> $q[0] = 2
> $q[1] = 4
> $q[2] = 5
> $q[3] = 3
>
> I'd like to be able to loop through this array via a While loop, and
> echo the contents of these array elements back to the screen.
>
> When I try something like:
>
> for($i = 0; $i < 4; $i++) {
> echo $q[i];
> echo eval("$q[i]");
> echo eval("\$q[" . i . "]");
> }
>
> I get the "String" instead of the "Contents". For example, the output
> is $q[0] instead of 2, $q[1] instead of 4, etc.
>

Use echo $q[$i].


--
Oli

 

Navigation:

[Reply to this 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

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