| Bug #31134 | foreach() semantics broken between 4.3.9 and 4.3.10 | ||||
|---|---|---|---|---|---|
| Submitted: | 16 Dec 2004 8:24pm UTC | Modified: | 16 Dec 2004 9:17pm UTC | ||
| From: | jlabonsk at eportation dot com | Assigned to: | |||
| Status: | Bogus | Category: | Scripting Engine problem | ||
| Version: | 4.3.10 | OS: | Linux | ||
| Votes: | 6 | Avg. Score: | 5.0 ± 0.0 | Reproduced: | 4 of 4 (100.0%) |
| Same Version: | 4 (100.0%) | Same OS: | 2 (50.0%) | ||
[16 Dec 2004 8:36pm UTC] jsjohnst@php.net
I can also confirm this is an issue.
[16 Dec 2004 9:17pm UTC] jsjohnst@php.net
Same issue as: http://bugs.php.net/bug.php?id=31108 Upgrade Zend Optimizer and it fixes it.

Description: ------------ The foreach($array as $key) construct returns an array for $key, instead of just the key. This breaks many scripts that count on $key being a scalar (and well, the key). Reproduce code: --------------- $test = array(2, 3, 4, 5); foreach($test as $key){ print_r($key); } Expected result: ---------------- 2345 Actual result: -------------- Array ( [0] => 2 [1] => 0 ) Array ( [0] => 3 [1] => 1 ) Array ( [0] => 4 [1] => 2 ) Array ( [0] => 5 [1] => 3 )