Re: Splitting string
| From: | Robert Cummings | Date: | Sun, 10 Dec 2006 10:46:32 +0000 |
| Subject: | Re: Splitting string | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-245686@lists.php.net to get a copy of this message | ||
On Sun, 2006-12-10 at 03:21 -0600, Larry Garfield wrote:
> I think the easiest way, if you can guarantee exactly 50 spaces as the
> separator, is to simply explode() it.
>
> $string = "EVOLUTION DEAR GOD
> BOYZ_II_MEN ";
>
> $arr = explode(str_repeat(' ', 50), $string);
>
> You could also use a regex, but that's probably overkill if your separator is
> that simple. If it's not, then you may need a regex.
If it's just 2 or more spaces (since don't want to confuse actual word
separation within a field) then you can use split with a regex as
follows:
$arr = split( ' {2,}', $string );
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com
|
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'