From:             jw at coffeecup dot com
Operating system: OS X
PHP version:      5.2.3
PHP Bug Type:     Scripting Engine problem
Bug description:  Foreach Referencing Problem

Description:
------------
I get a syntax error when I cast the array_expression portion of a foreach
loop to an array while using the & operator on the value portion.

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

print_r($arr);

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

Actual result:
--------------
Parse error: syntax error, unexpected '&', expecting T_STRING or
T_VARIABLE or '$' 

-- 
Edit bug report at http://bugs.php.net/?id=42384&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=42384&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=42384&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=42384&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=42384&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=42384&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=42384&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=42384&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=42384&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=42384&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=42384&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=42384&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=42384&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=42384&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=42384&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=42384&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=42384&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=42384&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=42384&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=42384&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=42384&r=mysqlcfg

Reply via email to