note 45040 deleted from function.explode by felipe
| From: | felipe@php.net | Date: | Thu, 03 Jan 2008 02:13:08 +0000 |
| Subject: | note 45040 deleted from function.explode by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-134703@lists.php.net to get a copy of this message | ||
Note Submitter: ian at illumen dot co dot uk
----
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.