foreach in php4

From: Date: Tue, 05 Jul 2005 05:40:26 +0000
Subject: foreach in php4
Groups: php.general 
Request: Send a blank email to php-general+get-218102@lists.php.net to get a copy of this message
I am on php 4.x. I see that in php5 I can do this (not the & before $value): $arr = array(1, 2, 3, 4); foreach ($arr as &$value) { $value = $value * 2; } // $arr is now array(2, 4, 6, 8) In order to create the same effect, I have been doing this: $pre_arr = array(1, 2, 3, 4); $arr = array(); foreach ($pre_arr as &$value) { $arr[] = $value * 2; } // $arr is now array(2, 4, 6, 8) Is there a better way? Thanks. Dotan Cohen http://lyricslist.com/lyrics/artist_albums/327/martin_ricky.php Martin, Ricky Song Lyrics

« previous php.general (#218102) next »