Bug #11541 Updated: weird behaviour with references and foreach
| From: | jens dot dreger at physik dot fu-berlin dot de | Date: | Mon, 18 Jun 2001 18:29:54 +0000 |
| Subject: | Bug #11541 Updated: weird behaviour with references and foreach | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-56668@lists.php.net to get a copy of this message | ||
ID: 11541
User Update by: jens.dreger@physik.fu-berlin.de
Status: Open
Bug Type: Scripting Engine problem
Operating system: Linux Redhat 6.2
PHP Version: 4.0.4pl1
Description: weird behaviour with references and foreach
well, maybe this behaviour is not so weird as I tought...
the problem I had, was that the line taking the reference
and the foreach-statement were far apart, and I'd really
like to have localized variables in the foreach, like
foreach($arr as (my $val))...
Previous Comments:
---------------------------------------------------------------------------
[2001-06-18 14:20:23] jens.dreger@physik.fu-berlin.de
<?php
echo "<small><pre>";
/* for some reason the following code magically kills
an array value, or better, overwrites it with another one.
might be related to bug #6417 */
$arr = array('a','b');
$ref =& $arr[0];
print_r($arr);
/* gives: Array ( [0] => a [1] => b ) */
foreach($arr as $ref);
print_r($arr);
/* gives: Array ( [0] => b [1] => b ) */
?>
---------------------------------------------------------------------------
Full Bug description available at: http://bugs.php.net/?id=11541