RE: [PHP] Split(), Explode()..
| From: | David Robley | Date: | Thu, 19 Oct 2000 04:47:41 +0000 |
| Subject: | RE: [PHP] Split(), Explode().. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-21088@lists.php.net to get a copy of this message | ||
On Thu, 19 Oct 2000, Maxim Maletsky wrote:
>
> 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..
For - while - do while whatever kind of loop you like :-) Control it with
count($array) which tells the number of elements in an array.
Problem: take a string and separate each character with a space (untested);
$string = 'hello world';
for ($i = 0; $i < $count($string); $i++) {
$newstring[] = $string[$i] . ' ';
}
If you need, check that the character you are dealing with is not a space
before appending a space.
The preg_split solution is more elegant, but doesn't differentiate between
spaces and other characters.
--
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