Re: Splitting string

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.          |
`------------------------------------------------------------'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux