PHP has a function str_split
that can be used to convert a string to an array. In PHP versions before 8.2, the str_split
function returns an array with a single empty string entry for empty string (str_split('') -> ['']
). This behavior is unexpected and can cause issues.
Since PHP 8.2, the str_split
returns an empty array for an empty string (str_split('') -> []
).
<?php
var_dump(str_split('')); // array(0) {}
Leave a Comment
Cancel reply