You are here: Re: Looping through arrays with foreach « PHP Programming Language « IT news, forums, messages
Re: Looping through arrays with foreach

Posted by Richard Levasseur on 03/31/06 19:22

It should be said that foreach operates on a copy of the array.
Changes to $value won't will not affect the original array.

With PHP5, the referential foreach was added, which aliases $value to
the original value in the array.
foreach($array as $key => & $value) { ... }
It should also be noted that $value will still exist as a reference
after the foreach() is over, thus assignments to $value will affect the
array also, so you much unset() it to prevent undesired side effects.

More information is available in the manual at:
http://us2.php.net/manual/en/control-structures.foreach.php

 

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

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