From: mdunn at escindex dot com Operating system: FreeBSD 4.10 PHP version: 5.0.5 PHP Bug Type: Arrays related Bug description: Foreach value overwritten
Description: ------------ According to the documentation "foreach" operates on a copy of the specified array and not the array itself. I believe that in PHP5 something has been messed up as it works in PHP4. There was a logic error in our script (missing double ==), however in PHP4 it had no effect on the outcome. In PHP5 it actually changed the value. Screen shots available at http://ww1.escindex.com/phpbug/ Reproduce code: --------------- $items['product_type'] = 'CPKG'; $items['product_id'] = 2; foreach($items as $item) { if($item->product_type == 'CPKG' && ($item->product_id = 1 || $item->product_id == 2)) { Expected result: ---------------- $items['product_type'] = 'CPKG'; $items['product_id'] = 2; Actual result: -------------- $items['product_type'] = 'CPKG'; $items['product_id'] = 1; -- Edit bug report at http://bugs.php.net/?id=35267&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=35267&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=35267&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=35267&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=35267&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=35267&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=35267&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=35267&r=needscript Try newer version: http://bugs.php.net/fix.php?id=35267&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=35267&r=support Expected behavior: http://bugs.php.net/fix.php?id=35267&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=35267&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=35267&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=35267&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=35267&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=35267&r=dst IIS Stability: http://bugs.php.net/fix.php?id=35267&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=35267&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=35267&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=35267&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=35267&r=mysqlcfg
