PHP explode() function


In this article, We will explain to you PHP explode() function with example.

PHP explode() function

The explode() function is a string function. which is used to convert the string into array. so you can see our PHP String Function example.

Syntax

explode(separator,string,limit);

Paramerter Option

separatorThis is Required Paramerter. Specifies where to break the string
stringThis is Required Paramerter and use the string
limitThis is Required Optional. specifies the return array limit

Example

<?PHP
    $data = explode(" ","This is My website");
    $data1 = explode(" ","This is My website");
    echo "
";
    print_r($data);
    echo "
"; echo "
";
    print_r($data1);
    echo "
"; ?>

Output

Array
(
    [0] => This
    [1] => is
    [2] => My
    [3] => website
)
Array
(
    [0] => This
    [1] => is My website
)