|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-09-18 09:31 UTC] jani@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 03 15:00:01 2025 UTC |
Description: ------------ key function within foreach array does not start from the very beginning of the array instead it starts from the 2nd element Reproduce code: --------------- $courses= array( 1=>"test", 2=>"test2", 3=>"test3" ); echo key($courses)."\n"; foreach($courses as $key=>$course){ echo $key ." ". $course."\n"; } reset($courses); echo "\n"; echo key($courses)."\n"; foreach($courses as $course){ echo key($courses) ." ". $course."\n"; next($courses); } Expected result: ---------------- 1 1 test 2 test2 3 test3 1 1 test 2 test2 3 test3 Actual result: -------------- 1 1 test 2 test2 3 test3 1 2 test 3 test2 test3