From:             
Operating system: Linux
PHP version:      Irrelevant
Package:          Scripting Engine problem
Bug Type:         Bug
Bug description:foreach-statement manipulates array (in a special case)

Description:
------------
The test script manipulates the last entry of $my_array instead of all or
leaving everything as it is.



my php version: 5.2.10

Test script:
---------------
<?

$my_Array[] = 'a';

$my_Array[] = 'b';

$my_Array[] = 'c';

$my_Array[] = 'd';



echo '<pre>1:' . print_r($my_Array, true) . '</pre>';



foreach($my_Array as &$value){

}



echo '<pre>2:' . print_r($my_Array, true) . '</pre>';



foreach($my_Array as $value){

}



echo '<pre>3:' . print_r($my_Array, true) . '</pre>';

?>

Expected result:
----------------
3:Array

(

    [0] => a

    [1] => b

    [2] => c

    [3] => d

)

Actual result:
--------------
3:Array

(

    [0] => a

    [1] => b

    [2] => c

    [3] => c

)

-- 
Edit bug report at http://bugs.php.net/bug.php?id=51951&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=51951&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=51951&r=trysnapshot53
Try a snapshot (trunk):              
http://bugs.php.net/fix.php?id=51951&r=trysnapshottrunk
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=51951&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=51951&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=51951&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=51951&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=51951&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=51951&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=51951&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=51951&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=51951&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=51951&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=51951&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=51951&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=51951&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=51951&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=51951&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=51951&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=51951&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=51951&r=mysqlcfg

Reply via email to