top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

PHP: What is the difference between Split and Explode?

+2 votes
388 views
PHP: What is the difference between Split and Explode?
posted Mar 26, 2014 by Riteshwar

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

The split() function splits the string into an array using a regular expression and returns an array.
The explode() function splits the string by string.

split uses regular expressions, while explode works with delimiter characters and split is deprecated in PHP 5.3.

Ex:
split(',','Hi, and Where are you');
returns array('Hi,', 'and Where are you')

explode('and','Hi, and Where are you');
returns array('Hi,', 'Where are you')

answer Mar 26, 2014 by Pavan P Naik
...