RE: [PHP] Split(), Explode()..
| From: | Matthias Endler | Date: | Thu, 19 Oct 2000 04:34:04 +0000 |
| Subject: | RE: [PHP] Split(), Explode().. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-21070@lists.php.net to get a copy of this message | ||
Hi Maxim,
> I have a simple (hopefully) question:
>
> I am trying to reformat the string by letters:
>
> $string = explode("", 'Hello World');
> echo implode (' ', $string);
>
> What I want is to separate each character of the string by whitespaces.
> Plus I want to keep the array ($string) for feature use.
>
> The code above gives me the following errors:
> Warning: Empty delimiter in /blah/blah.html on line 93
> Warning: Bad arguments to implode() in /blah/blah.html on line 94
>
> I also tried to use split:
>
> $string = split ("", 'Hello World');
> echo implode (' ', $string);
>
> and the errors received were:
> Warning: unexpected regex error (14) in /blah/blah.html on line 93
> Warning: Bad arguments to implode() in /blah/blah.html on line 94
>
> Anyone has an idea how to do it?
> Any function I don't know that does that?
>
> Can a loop help me? Regex? (BTW, the speed is pretty important)
I had the same problem yesterday...
$string = preg_split("//", 'Hello World');
that works.
Cheers,
Matthias