PHP explode Function

What is explode Function in string?


The "explode" function always used to break or split a string into an array in PHP.



In the above syntax, "seperator" specifies where to break the strings, "string" specifies the strings to be split,"limit" specifies the number of array elements to be returned.

Example :

$str = "Hey how are you!";
print_r(explode(" ",$str));
Result :

[0] => Hey
[1] => how
[2] => are
[3] => you!

In the above PHP example the string "$str" is split into 4 array elements based on the blankspace between words.

PHP Topics

Ask Questions

Ask Question