Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

strsplit() With Empty String

strsplit() splits a string into smaller strings of the same size. Until PHP 8.2, it used to 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.

Extension

© 2023-2026, Damien Seguy - Exakat