|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-01-07 21:05 UTC] sniper@php.net
[2005-01-07 21:08 UTC] walter at unpleasant dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 22 12:00:02 2025 UTC |
Description: ------------ When explode() explodes a string that starts with the delimiter, it returns an array that confuses reset(). The array is not empty, but reset()ing it returns FALSE. The same thing happens with split(). This messes up when you try to iterate over the result like this: for($i = reset($array);$i;$i = next($array) { ... } Reproduce code: --------------- $array = split(',', ',a,b,c'); echo count($array) . "Count is \n"; if(reset($array) == FALSE) echo "Can't happen.\n"; Expected result: ---------------- If I understand the semantics of reset() correctly, it should only returns FALSE on empty arrays. The array above is clearly not empty (count($array) returns 4), so resetting it should not return FALSE. Actual result: -------------- The above script prints out this when run: Count is 4 Can't happen.