What is the difference between explode and split?

Split - Splits string into array by regular expression.
Explode - Split a string by string

Hope this helps

Showing Answers 1 - 16 of 16 Answers

Balakrishnan

  • Nov 30th, 2006
 

hi, explode function split a string by string. for example, explode(" and", "india and pakistan and srilanka"); this function will return an array it contanis india,pakistan,srilanka. split function also spliting the string by regular expressions for example, split(" :", "india : pakistan : srilanka"); this function will return an array it contanis india,pakistan,srilanka.

kannan

  • Jan 20th, 2007
 

hi,

the difference is:

in split we can use regular expression in the search field

wheras in  explode we cant.

Qazi

  • Mar 21st, 2007
 

In Split You can use regular Expression
like

split('[/.-]', $string);

Cyprian

  • Jul 13th, 2011
 

split is deprecated, use preg_split instead

  Was this answer useful?  Yes

abc

  • Sep 12th, 2011
 

explode function is used to convert string into array & split is used to return an array

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions