How to Use Explode() function in PHP?

Explode() function

Explode() function in PHP is used to convert a string into an array.




//implode function example
$string = "Experts Quiz is a Programming Website";
$res = explode(" ",$string);
echo "<pre>";
print_r( $res );


[0] => Experts
[1] => Quis
[2] => is
[3] => a
[4] => Programming
[5] => website

In the above example we can see that we have set a string “Experts Quiz is a Programming Website”. And to convert this string into array we have used explode() function. In the explode function, two parameters have to be set, first that is the separator parameter, if the string is to be broken, then we can break the string with what will be common in the both of the word in the string.“Experts Quiz is a Programming Website” If there is too much space after every word in this string, then we can break the string with space. And after the string space break, each word will be assigned to the index of the array as if “Hello” word is at array[0] index and “this” is assign in array[1] index, then this is the type of string. Will be stored in the index of each word array.