note 60806 modified in control-structures.foreach by danbrown
| From: | danbrown@php.net | Date: | Tue, 28 Apr 2009 13:07:14 +0000 |
| Subject: | note 60806 modified in control-structures.foreach by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-153915@lists.php.net to get a copy of this message | ||
Pretty weird but for future reference
<?php
//doesn't multiply the last value
foreach ($ar as &$v){
$v *= 2;
}
foreach($ar as $v){
echo $v. "<br>";
}
//works fine
foreach ($ar as &$o){
$o *= 2;
}
foreach($ar as $v){
echo $v. "<br>";
}
?>
--was--
Pretty weird but for future reference
//doesn't multiply the last value
foreach ($ar as &$v){
$v *= 2;
}
foreach($ar as $v){
echo $v. "<br>";
}
//works fine
foreach ($ar as &$o){
$o *= 2;
}
foreach($ar as $v){
echo $v. "<br>";
}
http://php.net/manual/en/control-structures.foreach.php