What is the difference between split() and explode()?

Theodore R. Smith picture Theodore R. Smith · Sep 4, 2010 · Viewed 54.9k times · Source

The PHP manual for split() says

This function has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged...Use explode() instead.

But I can't find a difference between split() and explode(). join() hasn't been deprecated, so what gives?

Answer

BoltClock picture BoltClock · Sep 4, 2010

It's been deprecated because

  • explode() is substantially faster because it doesn't split based on a regular expression, so the string doesn't have to be analyzed by the regex parser
  • preg_split() is faster and uses PCRE regular expressions for regex splits

join() and implode() are aliases of each other and therefore don't have any differences.