What is the difference between explode and split?
Last updated 4 years, 2 months ago | 1178 views 75 5
The explode() and split() both function is use to split a string into an array. But the difference is explode() function splits a string into array by string where as Split function splits string into array by regular expression.
Let's see an example from both
<?php $explode = explode("and", "Roshan and Shyam and Rahul"); print_r($explode); ?> //Output Array (  => Roshan  => Shyam  => Rahul )
<?php $split = split(" :", "Roshan : Shyam : Rahul"); print_r($split); ?> //Output Array (  => Roshan  => Shyam  => Rahul )
Above both function is returning the same array.