|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2012-12-13 08:34 UTC] laruence@php.net
[2012-12-13 08:34 UTC] laruence@php.net
-Status: Open
+Status: Not a bug
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 22:00:01 2025 UTC |
Description: ------------ foreach seems to increment the pointer used by current() once even if foreach loops multiple times. Seems to me that it should not increment it at all or increment it multiple times. Not once and that's it. Test script: --------------- <?php $a = array(1, 2, 3, 4, 5); foreach ($a as $key => $elem) { echo "$key = $elem"; echo ' = '; var_dump(current($a)); } ?> Expected result: ---------------- 0 = 1 = int(1) 1 = 2 = int(1) 2 = 3 = int(1) 3 = 4 = int(1) 4 = 5 = int(1) Actual result: -------------- 0 = 1 = int(2) 1 = 2 = int(2) 2 = 3 = int(2) 3 = 4 = int(2) 4 = 5 = int(2)