Firstly let us know why we use explode() function in php ?
explode() function basically used for breaking a string into an array in php.
explode() function is binary-safe in php.
explode() function syntex is given bellow:
explode(',',string,0)
means there are three main important things in explode() function
1-separator(',')
2-string
3-limit
You can take reference form below example of explode() function in php.
?php
$Colorstr = 'red,blue,pink,green';
//here $Colorstr is a variable in which store all string of color name.
// now call explode() and give 0 limit
print_r(explode(',',$Colorstr,0));
print "<br-->";
//now call explode() and give positive limit 2
print_r(explode(',',$Colorstr,4));
?>
so when you will give limit 0 then output will come:
Array ( [0] => red
blue,pink,green
)
and when you will give limit 4 then output will come:
Array (
[0] => red
[1] => blue
[2] => pink
[3] => green
)
0 Comment(s)