note 45040 added to function.explode
| From: | ian at illumen dot co dot uk | Date: | Tue, 24 Aug 2004 08:30:44 +0000 |
| Subject: | note 45040 added to function.explode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-79828@lists.php.net to get a copy of this message | ||
If you split an empty string, you get back a one-element array with 0 as the key and an empty string
for the value.
<?php
$str = '';
$foo = explode( ":", $str );
print_r( $foo );
$foo = split( ":", $str );
print_r( $foo );
$foo = preg_split( "/:/", $str );
print_r( $foo );
?>
In all three cases prints
Array
(
[0] =>
)
This of course means that you must explicitly check to see if the value of the first element is
blank, or must check to see if the string being split is blank.
----
Manual Page -- http://www.php.net/manual/en/function.explode.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+45040
Delete -- http://master.php.net/manage/user-notes.php?action=delete+45040&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+45040&report=yes
Search -- http://master.php.net/manage/user-notes.php