How to use explode in PHP
In this article, I will explain how the explode() function can be used in PHP.
explode() function in PHP
- The explode() function is used to break a string into an array.
- In explode() function, Separator cannot be an empty string.
Syntax
explode(separator,string,limit) |
Parameter
- separator string is required parameter. It is boundary where to break the string.
- string string is required parameter. the string to be split
- limit limit is optional parameter. the maximum number of elements in the output array.
Example
The following example show to how the explode() function can be used in PHP.
<html>
<body>
<h3 style="color: blueviolet;">explode() function example in PHP</h3>
<?php
$str = "Welcome to all C-sharpcorner user's <br/> Have a nice day....".'<br/>';
print_r(explode(" ",$str));
?>
</body>
</html>
|
Output
You may also want to read these related articles here
Ask Your Question
Got a programming related question? You may want to post your question here