note 64126 added to function.current
| From: | metapundit at osu1 dot php dot net | Date: | Sat, 08 Apr 2006 03:31:49 +0000 |
| Subject: | note 64126 added to function.current | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-107550@lists.php.net to get a copy of this message | ||
The warning that current returns false if the current array value is a 0 or ""
doesn't seem to be true with my version of php (4.3.10). eg
$a=array("");var_dump(current($a);
prints out string(0) "". Of course if you store the boolean false in your array, you
can't rely on current to tell if you're at the end of your array anyway since it will
return false as a value and also false as the end of the array... Is the best safe equivalent to
if(current($array) === false)
to use instead
if(!is_null(key($array))
Seems safe to me since Null is not a valid key and will never be returned by key() unless at the end
of the array...
----
Server IP: 216.194.113.175
Probable Submitter: 69.225.32.172
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.current.php
Edit -- http://master.php.net/note/edit/64126
Del: integrated -- http://master.php.net/note/delete/64126/integrated
Del: useless -- http://master.php.net/note/delete/64126/useless
Del: bad code -- http://master.php.net/note/delete/64126/bad+code
Del: spam -- http://master.php.net/note/delete/64126/spam
Del: non-english -- http://master.php.net/note/delete/64126/non-english
Del: in docs -- http://master.php.net/note/delete/64126/in+docs
Del: other reasons-- http://master.php.net/note/delete/64126
Reject -- http://master.php.net/note/reject/64126
Search -- http://master.php.net/manage/user-notes.php