PHP:Split a String

From Progzoo
Jump to navigation Jump to search

You can use explode to break a single string into an array of strings.

explode

You can specify the string that delimits. explode(' ',$s) will split the string $s on every space character.


[Font] [Default] [Show] [Resize] [History] [Profile]

preg_split on regular expression

You can use a regular expression. /\s+/ will match one or more consecutive white space characters - including tabs and line end markers.


[Font] [Default] [Show] [Resize] [History] [Profile]