note 72351 added to control-structures.foreach
| From: | TimonVanOverveldt at osu1 dot php dot net | Date: | Mon, 15 Jan 2007 16:41:08 +0000 |
| Subject: | note 72351 added to control-structures.foreach | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-121738@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 87.238.162.147
Probable Submitter: 84.195.229.122
----
Manual Page -- http://www.php.net/manual/en/control-structures.foreach.php
Edit -- https://master.php.net/note/edit/72351
Del: integrated -- https://master.php.net/note/delete/72351/integrated
Del: useless -- https://master.php.net/note/delete/72351/useless
Del: bad code -- https://master.php.net/note/delete/72351/bad+code
Del: spam -- https://master.php.net/note/delete/72351/spam
Del: non-english -- https://master.php.net/note/delete/72351/non-english
Del: in docs -- https://master.php.net/note/delete/72351/in+docs
Del: other reasons-- https://master.php.net/note/delete/72351
Reject -- https://master.php.net/note/reject/72351
Search -- https://master.php.net/manage/user-notes.php