In PHP, when I run the following command:
$text = "";
$arr = preg_split('/,/', $text, PREG_SPLIT_NO_EMPTY);
print_r($arr);
I get the following array with a single empty element:
Array
(
[0] =>
)
Yet, if I run it with -1 as the limit:
$text = "";
$arr = preg_split('/,/', $text, -1, PREG_SPLIT_NO_EMPTY);
print_r($arr);
I get a completely empty array:
Array
(
)
Why is this the case? According to the PHP manual -1 is the default value so I would expect the results to be the same in both cases.
strlen()function?