strsplit() With Empty String¶
strstplit() splits a string into smaller strings of the same size. Until PHP 8.2, it would return an array with an empty string when splitting an empty string. Since then, it returns an empty array.
This has impact on the code after, in processing or testing the result of the split.
PHP code¶
<?php
var_dump(str_split('', 3));
?>
Before¶
Array
(
[0] =>
)
After¶
Array
(
)
PHP version change¶
This behavior changed in 8.2