Re: foreach in php4

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux