Reply to Re: Looping through arrays with foreach

Your name:

Reply:


Posted by Oli Filth on 03/31/06 13:40

Sjoerd said the following on 31/03/2006 11:29:
> Another method to loop through an array:
> for ($i = 0; $i < count($arr); $i++) {
> echo "value: $arr[$i]\n";
> }
>
> Consider this array:
> array(5 => "Five");
>
> The above for-loop would loop from elements 0 through 5, while
> only one element exists.

Actually, no it wouldn't. count($arr) == 1, so it attempts to access
only $arr[0], which clearly doesn't exist.




--
Oli

[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

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