You are here: Re: [PHP] foreach in php4 « PHP « IT news, forums, messages
Re: [PHP] foreach in php4

Posted by "Richard Lynch" on 07/06/05 00:44

On Mon, July 4, 2005 10:40 pm, Dotan Cohen said:
> $pre_arr = array(1, 2, 3, 4);
> $arr = array();

foreach ($pre_arr as $key=>$value) {

$pre_arr[$key] = $value * 2;

//> $arr[] = $value * 2;
> }
> // $arr is now array(2, 4, 6, 8)
>
> Is there a better way? Thanks.

Whether that's better or not depends on what you mean by "better"... :-)

PS I dunno if I got the foreach syntax right or not. Never use it.

--
Like Music?
http://l-i-e.com/artists.htm

 

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

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