note 76686 added to function.explode
| From: | thomas at tgohome dot com | Date: | Thu, 26 Jul 2007 09:47:51 +0000 |
| Subject: | note 76686 added to function.explode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-128935@lists.php.net to get a copy of this message | ||
This had me for a moment. A quick gotcha, for me, because it was causing some problems in a script
of mine.
If you explode an empty string, you'll get an array with one element - an empty string, and not
an empty array or string as you may think.
For example:
<?php
$string = "";
$numbers = explode(",", $string); // Array with one element, "".
$string = "1,2,3";
$numbers = explode(",", $string); // Array with three elements
?>
----
Server IP: 194.145.210.3
Probable Submitter: 81.86.162.169
----
Manual Page -- http://www.php.net/manual/en/function.explode.php
Edit -- https://master.php.net/note/edit/76686
Del: integrated -- https://master.php.net/note/delete/76686/integrated
Del: useless -- https://master.php.net/note/delete/76686/useless
Del: bad code -- https://master.php.net/note/delete/76686/bad+code
Del: spam -- https://master.php.net/note/delete/76686/spam
Del: non-english -- https://master.php.net/note/delete/76686/non-english
Del: in docs -- https://master.php.net/note/delete/76686/in+docs
Del: other reasons-- https://master.php.net/note/delete/76686
Reject -- https://master.php.net/note/reject/76686
Search -- https://master.php.net/manage/user-notes.php