I'm trying to split a string by one or more spaces, but the below isn't working..instead it is returning the whole string as a singular array.
$str = 'I am a test';
$parts = preg_split('/\s+/', $str, PREG_SPLIT_NO_EMPTY);
print_r($parts);
Here is what it returns:
Array
(
[0] => I am a test
)
flags
is the 4th parameter to preg_split
, not the 3rd.