explode() Function in PHP

Last Updated on April 30, 2024 by Roshan Parihar

PHP explode() function splits or breaks an array into strings. It splits an array based on the delimiter. You have to specify the character delimiter (like comma(,)) in a string from where the string will split.

Syntax

explode(separator, string, limit)

Parameter Description

Name Description
separator Required. Specify the character present in a string where to split or break an array
string Required. The string is to be broken into an array.
limit optional. The no of array elements to return.

  • Positive or greater than zero (0): returns an array with maximum of limit elements with last element containing rest of the string
  • Negative or less than zero (0): returns an array except for the last –limit element of the string
  • zero (0): returns an array with one element the string

Let’s find out the use of the PHP explode() Function with the examples given below.

Examples of PHP explode() Function

Example 1

Leave a comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.