Connecting Tech Pros Worldwide Forums | Help | Site Map

split q

Alexander Ross
Guest
 
Posts: n/a
#1: Jul 17 '05
is there an easy way to split a string on SPACE except if that SPACE is
within QUOTES?

i.e. - $str = red green blue yellow "blue green" returns
[red,green,blue,yellow,blue green]

?



Bruno Desthuilliers
Guest
 
Posts: n/a
#2: Jul 17 '05

re: split q


Alexander Ross wrote:[color=blue]
> is there an easy way to split a string on SPACE except if that SPACE is
> within QUOTES?
>
> i.e. - $str = red green blue yellow "blue green" returns
> [red,green,blue,yellow,blue green]
>
> ?
>[/color]
preg_split() should do it...
http://www.php.net/manual/en/function.preg-split.php


Closed Thread