PHP - What is the difference between Split and Explode?

What is the difference between Split and Explode?

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.

Example:
explode (" this", "this is a string");     //will return “Is a string”
Split (" + ", "This+ is a string")

What is the difference between Split and Explode in PHP?

The split() function splits the string into an array using a regular expression and returns an array.
Example:
split(:India:Pakistan:Srilanka);

Returns an array that contains India, Pakistan, Srilanka.

The explode() function splits the string by string.
Example:
explode(and India and Pakistan and Srilanka);

Returns an array that contains India, Pakistan, Srilanka.
PHP - What is the difference between echo and print statement?
PHP - Echo can accept multiple expressions while print cannot.....
PHP - What is CAPTCHA?
PHP - CAPTCHA is a test to determine if the user using the system...
PHP - What is difference between developing website using Java and PHP?
PHP - In order to make interactive pages, java uses JSP (Java Server pages)....
Post your comment
Discussion Board
PHP INTERVIEW QUESTION WITH EXAMPLE
FRESHER
RAKESH KUMAR 10-28-2014