|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-02-01 11:47 UTC] johannes@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 08:00:02 2025 UTC |
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