Empty delimiter

Description

The explode() function doesn’t work without a non-empty delimiter. Use an alternative, such as str_split().

Example

<?php

print_r(explode('', 'abc')); // Not possible with an empty delimiter

print_r(str_split(1, 'abc'));

?>

Solutions

  • Use str_split() to split the string into individual characters.

  • Access to the different elements.

See Also