note 120203 added to control-structures.foreach
| From: | mustaroad | Date: | Tue, 22 Nov 2016 06:58:47 +0000 |
| Subject: | note 120203 added to control-structures.foreach | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-207461@lists.php.net to get a copy of this message | ||
also we can use reference with $key => &$val :
$arr = [100, "sub" => 10, "fun" => 1000];
foreach($arr as $key => &$val) {
if($key === "fun")
$val *= 2;
}
unset($val);
print_r($arr);
----
Server IP: 72.52.91.14
Probable Submitter: 37.236.112.33
----
Manual Page -- http://php.net/manual/en/control-structures.foreach.php
Edit -- https://master.php.net/note/edit/120203
Del: integrated -- https://master.php.net/note/delete/120203/integrated
Del: useless -- https://master.php.net/note/delete/120203/useless
Del: bad code -- https://master.php.net/note/delete/120203/bad+code
Del: spam -- https://master.php.net/note/delete/120203/spam
Del: non-english -- https://master.php.net/note/delete/120203/non-english
Del: in docs -- https://master.php.net/note/delete/120203/in+docs
Del: other reasons-- https://master.php.net/note/delete/120203
Reject -- https://master.php.net/note/reject/120203
Search -- https://master.php.net/manage/user-notes.php