What would be a suitable regular expression to split a string into all spaces? There may also be several spaces between the two tokens, and in the end, spaces should be ignored.
What I still have:
<?php $tags = "unread dev test1 "; $tagsArr = preg_split("/ +/", $tags); foreach ($tagsArr as $value) { echo $value . ";"; }
This gives me the following result:
"unread;dev;test1;;"
As you can see, this does not ignore spaces at the end, because the correct output should be:
"unread;dev;test1;"
source share