Hi friends,
I want to know that What is the difference between Split and Explode?
Thanks
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted Dec 21, 2011, 7:35 AM EST
Both the functions are used to Split a string. However, Split is used to split a string using a regular expression. On the other hand, Explode is used to split a string using another string.
E.g explode (" this", "this is a string"); will return "Is a string"
Split (" + ", "This+ is a string")
The split() function splits the string into an array using a regular expression and returns an array.
The explode() function breaks a string into an array.
ex
$str = "Hello world. It's a beautiful day.";
print_r (explode(" ",$str));
?>
output
[0] => Hello
[1] => world.
[2] => It's
[3] => a
[4] => beautiful
[5] => day.
Thanks
Sam HobbsRank #107 · 20.5K reputationPosted Dec 21, 2011, 9:31 AM EST
VulpesRank #55 · 29.2K reputationPosted Dec 21, 2011, 10:30 AM EST
Sam HobbsRank #107 · 20.5K reputationPosted Dec 21, 2011, 10:53 AM EST
I think it would be better to use the General forum instead of the ASP forum. Whatever forum is used, it will help if the language is specified when it is not the language that is this web site's namesake (the language that this web site is named for). This specific thread could have saved me time if it was specified as being a PHP question.
VulpesRank #55 · 29.2K reputationPosted Dec 21, 2011, 11:03 AM EST
http://www.javatalks.com/