ID:               40065
 Updated by:       [EMAIL PROTECTED]
 Reported By:      ugo at iliona dot net
 Status:           Bogus
 Bug Type:         Arrays related
 Operating System: Linux/BSD
 PHP Version:      5.2.0
 New Comment:

#29992 and it is not a bug.


Previous Comments:
------------------------------------------------------------------------

[2007-01-08 18:06:52] ugo at iliona dot net

Hmmm...
I haven't found a similar open bug in the database (I wouldn't have
posted it otherwise), but if you say that it is the same as another
one, that's okay for me as long as it is fixed in the next version :)

------------------------------------------------------------------------

[2007-01-08 17:55:24] [EMAIL PROTECTED]

Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

,

------------------------------------------------------------------------

[2007-01-08 17:42:34] ugo at iliona dot net

Description:
------------
Hello, 

This bug was tried on multiple Unix versions and multiple processors
(32/64bits), and multiple PHP5 versions (including 5.2.0), so it seems
really to be on the side of PHP.
After using a foreach with a referenced value, and then another foreach
(without the referenced value), the original array is broken.
Apparently, the last value of the array takes the value of the n - 1
last value.

I've reduced the problem to its simplest form and attached it to this
bug report.

Greeting, 

Ugo PARSI

Reproduce code:
---------------
<?php
$arr = array(1, 2, 3, 4);
foreach ($arr as &$value) {
   $value = $value * 2;
}
print_r($arr);
foreach ($arr as $value) {
   $value = $value;
}
print_r($arr);
?>

Expected result:
----------------
Array ( [0] => 2 [1] => 4 [2] => 6 [3] => 8 ) Array ( [0] => 2 [1] => 4
[2] => 6 [3] => 8 )

Actual result:
--------------
Array ( [0] => 2 [1] => 4 [2] => 6 [3] => 8 ) Array ( [0] => 2 [1] => 4
[2] => 6 [3] => 6 )


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=40065&edit=1

Reply via email to