note 109698 added to control-structures.foreach
| From: | dtowell | Date: | Sat, 11 Aug 2012 00:45:00 +0000 |
| Subject: | note 109698 added to control-structures.foreach | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-190037@lists.php.net to get a copy of this message | ||
References created by foreach hang around past their best-used-by date. For example, the following:
<?php
$a = array('abe','ben','cam');
foreach ($a as $k=>&$n)
$n = strtoupper($n);
foreach ($a as $k=>$n) // notice NO reference here!
echo "$n\n";
print_r($a);
?>
will result in:
ABE
BEN
BEN
Array
(
[0] => ABE
[1] => BEN
[2] => BEN
)
----
Server IP: 69.147.83.197
Probable Submitter: 74.195.32.53
----
Manual Page -- http://www.php.net/manual/en/control-structures.foreach.php
Edit -- https://master.php.net/note/edit/109698
Del: integrated -- https://master.php.net/note/delete/109698/integrated
Del: useless -- https://master.php.net/note/delete/109698/useless
Del: bad code -- https://master.php.net/note/delete/109698/bad+code
Del: spam -- https://master.php.net/note/delete/109698/spam
Del: non-english -- https://master.php.net/note/delete/109698/non-english
Del: in docs -- https://master.php.net/note/delete/109698/in+docs
Del: other reasons-- https://master.php.net/note/delete/109698
Reject -- https://master.php.net/note/reject/109698
Search -- https://master.php.net/manage/user-notes.php