Beware that it is not safe to assume there are no empty values returned by PREG_SPLIT_NO_EMPTY, nor that you will see no delimiters if you use PREG_SPLIT_DELIM_CAPTURE, as there are some edge cases where these are not true.
<?php
# As expected, splitting a string by itself returns two empty strings:
var_export(preg_split("/x/", "x"));
array (
0 => '',
1 => '',
)
# But if we add PREG_SPLIT_NO_EMPTY, then instead of an empty array, we get the delimiter.
var_export(preg_split("/x/", "x", PREG_SPLIT_NO_EMPTY));
array (
0 => 'x',
)
And if we try to split an empty string, then instead of an empty array, we get an empty string even with PREG_SPLIT_NO_EMPTY.
var_export(preg_split("/x/", "", PREG_SPLIT_NO_EMPTY));
array (
0 => '',
)
?>