ID:               45135
 Updated by:       [EMAIL PROTECTED]
 Reported By:      byraul at gmail dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Unknown/Other Function
 Operating System: linux
 PHP Version:      5.2.6
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

As explained by Felix.


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

[2008-05-30 09:04:43] felix dot devliegher at gmail dot com

This is not a bug, but expected behaviour. The last iteration of the 
foreach with reference value references itself, with a current value of

'one3' at that point, thus saving one3 as last value.

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

[2008-05-30 08:51:12] byraul at gmail dot com

Description:
------------
Reference problems

Reproduce code:
---------------
<?php
$matches = array(
    array('one0', 'two0', 'three0'),
    array('one1', 'two1', 'three1'),
    array('one2', 'two2', 'three2'),
    array('one3', 'two3', 'three3'),
    array('one4', 'two4', 'three4'),
);
foreach($matches as $key=>&$value)
{
}

foreach($matches as $value)
{
    echo $value[0] . PHP_EOL;
}

Expected result:
----------------
one0
one1
one2
one3
one4

Actual result:
--------------
one0
one1
one2
one3
one3


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


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

Reply via email to