RE: [PHP] Split(), Explode()..
| From: | Maxim Maletsky | Date: | Thu, 19 Oct 2000 04:44:20 +0000 |
| Subject: | RE: [PHP] Split(), Explode().. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-21073@lists.php.net to get a copy of this message | ||
So you're saying that a loop would be enough?
but how?
for() loop?
can you pass me a simple sketch of what you mean , just to give me an idea..
-----Original Message-----
From: David Robley [mailto:huntsman@hermes.nisu.flinders.edu.au]
Sent: Thursday, October 19, 2000 1:29 PM
To: Maxim Maletsky; 'PHP General List. (E-mail)'
Subject: Re: [PHP] Split(), Explode()..
On Thu, 19 Oct 2000, Maxim Maletsky wrote:
>
>
> Hello list,
> 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)
>
> Thanks folks!
Well, a string variable is simply an array of characters, so you could just
loop through the variable and assign each element(letter) with a space
appended to it (unless it is already a space?) to a new variable.
Consider how you deal with the last element - ie does it need a space
appended?
--
David Robley | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/
AusEinet | http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net