Logo

Programming-Idioms

History of Idiom 49 > diff from v8 to v9

Edit summary for version 9 by :

Version 8

2015-08-21, 23:23:44

Version 9

2015-08-21, 23:24:11

Idiom #49 Split a space-separated string

Build list chunks consisting in substrings of input string s, separated by one or more space characters.

Idiom #49 Split a space-separated string

Build list chunks consisting in substrings of input string s, separated by one or more space characters.

Code
$chunks = preg_split("/ +/", $s);
Code
$chunks = preg_split("/ +/", $s);
Comments bubble
To match one ore more spaces, use preg_split instead of explode.
Comments bubble
To match one ore more spaces, use preg_split instead of explode.
Doc URL
http://php.net/manual/en/function.preg-split.php
Origin
http://php.net/manual/en/function.preg-split.php