How can i get rid of trailing spaces in preg_split result without using preg_replace to first remove all spaces from $test string?
$test = 'One , Two, Thee ';
$test = preg_replace('/\s+/', ' ', $test);
$pieces = preg_split("/[,]/", $test);
If it must be
preg_split()(you actually required that in the question) then this might help:trim()is used to remove space before the first and behind the last element. (whichpreg_split()doesn’t do – it removes only spaces around the commas)