PHP Explode

The PHP explode( ) is used to break a string into an array.

The PHP explode( ) allow us to break a string into a smaller text with each break is represented the same symbol. This symbol is known as a delimiter.

Using the PHP explode( ), we can create an array from string.


  • Separator: It is required. It specifies where to break the string.
  • String: It is required. The string to split.
  • Limit: It is optional. It specifies the number of an array element to return.

Possible Values: Greater than 0: It returns an array with a maximum of elements.

Less than 0: It returns an array except for the last.

0: It returns an array with one element.

Note: We must ensure that the delimiter argument before the string argument.



In the above example, we have $str=”PHP explode.”

We made each name as an element of an array and accessed it individually, i.e.,

(explode(” ” ,$str));

Resulting Array Variable:

Example2(Limit Parameter):


Pin It on Pinterest

Share This