note 17094 deleted from function.explode by jimw
| From: | jimw@php.net | Date: | Fri, 07 Dec 2001 21:26:24 +0000 |
| Subject: | note 17094 deleted from function.explode by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-22018@lists.php.net to get a copy of this message | ||
If you intend to do the following
1. explode something
$array = explode("|", $string);
2. stick a value on to the end of the array
$array[] = "1234567890";
3. Then Implode it straight away.
$new_string = implode("|", $array);
Check that the original string ($string) has a value.
As exploding on an empty string and a string with one value
will both return 1.
If the string was empty the the new imploded string will look like this:-
"|1234567890"
Which is a pain when you come to explode it again as the first value in the array will be blank.
$string = "";
if ($string) != "")
{
$array = explode("|", $string);
}
else
{
$array = array();
}
$array[] = "1234567890";
$new_string = implode("|", $array);