note 72351 deleted from control-structures.foreach by googleguy
| From: | googleguy@php.net | Date: | Wed, 14 Nov 2012 22:32:38 +0000 |
| Subject: | note 72351 deleted from control-structures.foreach by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-191975@lists.php.net to get a copy of this message | ||
Note Submitter: Timon Van Overveldt
----
Why not just do this?
<?php
$arr = array(1, 2, 3, 4);
foreach ($arr as $i => $value) {
$arr[$i] = $value * 2;
}
// $arr is now array(2, 4, 6, 8)
?>
No need for references, so it works in both PHP4 and PHP5.