Explode a string with no delimiter in PHP

Posted by

I needed a way to split a string by the character and put the results in an array. Sounds like the perfect job for the explode function right? Well, according to the manual:

If delimiter is an empty string (“”), explode() will return FALSE

That’s a bummer.

I also tried str_split(‘whatever’) but that has some problems with foreign strings. But we can do something like this:

Enjoy! Let me know what other ways you can come up with to do something similar.

Leave a Reply

Your email address will not be published. Required fields are marked *