How to split a string into characters using preg_split without spaces?

Trying to split a string into characters and put into an array using preg_split, but with all the characters spaces.

$text = 'simple text';
$text_trim = trim($text);
$str = preg_split('//u',$text_trim,-1,PREG_SPLIT_NO_EMPTY);
July 2nd 19 at 17:10
2 answers
July 2nd 19 at 17:12
Solution
$str = preg_split( '/\s+|/u', $text_trim, -1, PREG_SPLIT_NO_EMPTY );
C "/\s+|/u" really worked. Thank you - nikita.Stracke commented on July 2nd 19 at 17:15
July 2nd 19 at 17:14
$text_trim = preg_replace('/[\s]+/u',",$text);
An empty array is created. Probably ^ does not work with space or tab - nikita.Stracke commented on July 2nd 19 at 17:17
: filter line before by using preg_replace for the regular season and all. - nikita.Stracke commented on July 2nd 19 at 17:20
With preg_replace as an option, but somehow still the spaces are not removed. - Kyleigh_Hills commented on July 2nd 19 at 17:23

Find more questions by tags ArraysProgrammingPHP