explode to edit. Arrays are easier to change than raw strings.
Replace one item. Index 1 becomes "js".
implode to rebuild. Same delimiter stitches the pieces.
Inverse pair. This is the usual explode ↔ implode workflow.
Frequently Asked Questions
explode() splits a string into an array of substrings using a delimiter. Each time the delimiter appears, a new array element begins. The delimiter itself is not kept in the pieces.
array explode(string $separator, string $string, int $limit = PHP_INT_MAX). Separator comes first, then the string. The optional limit controls how many pieces you get.
You get a one-element array with the whole original string. Example: explode(',', 'hello') returns ['hello'].
A positive limit caps the number of elements—the last one holds any leftover text. A negative limit drops that many elements from the end. A limit of 0 is treated as 1.
No. Since PHP 8.0, an empty separator throws a ValueError. To split into characters, use str_split() instead.