SPECIFICALLY for the OP's sample string, because each substring to be matched is a single word, you can use str_word_count().
Code: (Demo)
$str = ' red, green, blue ,orange ';
var_export(str_word_count($str,1)); // 1 means return all words in an indexed array
Output:
array (
0 => 'red',
1 => 'green',
2 => 'blue',
3 => 'orange',
)
This can also be adapted for substrings beyond letters (and some hyphens and apostrophes -- if you read the fine print) by adding the necessary characters to the character mask / 3rd parameter.
Code: (Demo)
$str = " , Number1 , 234, 0 ,4heaven's-sake , ";
var_export(str_word_count($str,1,'0..9'));
Output:
array (
0 => 'Number1',
1 => '234',
2 => '0',
3 => '4heaven\'s-sake',
)
Again, I am treating this question very narrowly because of the sample string, but this will provide the same desired output:
Code: (Demo)
$str = ' red, green, blue ,orange ';
var_export(preg_match_all('/[^, ]+/',$str,$out)?$out[0]:'fail');
Finally, if you want to split on commas with optional leading or trailing spaces, here is the call: (Demo)
var_export(
preg_split ('/ *,+ */', $str, 0, PREG_SPLIT_NO_EMPTY)
);