ID:               42384
 Updated by:       [EMAIL PROTECTED]
 Reported By:      jw at coffeecup dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Scripting Engine problem
 Operating System: OS X
 PHP Version:      5.2.3
 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

The value created by (array)$arr is a temporary variable which can't be
referenced.


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

[2007-08-22 16:21:55] jw at coffeecup dot com

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 this bug report at http://bugs.php.net/?id=42384&edit=1

Reply via email to