The explode()
function won't split with empty string
You can't php explode by an empty string to get an array of characters:
If delimiter is an empty string (""), explode() will return FALSE.
This is different from just doing $str[$i]
, because an array lets you easily replace one character with several without confusing iteration.
Rather than provide some common behavior for that case, or even any behavior at all, the language designers chose to make it an error condition. This makes it impossible to use the function in any sort of induction base case, and instead forces you to rely on checking for that situation manually and falling back on either php str_split or converting your delimiters into regular expressions and using php preg_split instead.