From: crashrox at gmail dot com
Operating system: SunOS 5.10 Generic_127
PHP version: 5.2.5
PHP Bug Type: Arrays related
Bug description: next function is not returning correctly
Description:
------------
Next function is not returning a value when it should be. Tried code
sample below on a linux and windows distro both running PHP 5.2.1 and
received desired results. When tested on SunOS 5.10 and PHP 5.2.4 the
undesired results appeared.
Reproduce code:
---------------
$array = array(
'key1' => array(
'sub1_key1',
'sub1_key2',
'sub1_key3',
'sub1_key4',
),
'key2' => array(
'sub2_key1',
'sub2_key2',
'sub2_key3',
'sub2_key4',
)
);
foreach($array as $key => $sub_array) {
foreach($sub_array as $sub_val) {
echo $sub_val;
if(next($sub_array))
echo ', ';
}
$next = next($array);
if(is_array($next)) {
echo '||||';
}
print_r($next);
}
Expected result:
----------------
sub1_key1, sub1_key2, sub1_key3, sub1_key4||||Array
(
[0] => sub2_key1
[1] => sub2_key2
[2] => sub2_key3
[3] => sub2_key4
)
sub2_key1, sub2_key2, sub2_key3, sub2_key4
Actual result:
--------------
sub1_key1, sub1_key2, sub1_key3, sub1_key4sub2_key1, sub2_key2, sub2_key3,
sub2_key4
--
Edit bug report at http://bugs.php.net/?id=44006&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=44006&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=44006&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=44006&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=44006&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=44006&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=44006&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=44006&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=44006&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=44006&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=44006&r=support
Expected behavior: http://bugs.php.net/fix.php?id=44006&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=44006&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=44006&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=44006&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=44006&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=44006&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=44006&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=44006&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=44006&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=44006&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=44006&r=mysqlcfg