Home » Php » split vs. explode in php

split vs. explode in php

Posted by: admin April 23, 2020 Leave a comment


What is the difference between explode and split in php?

How to&Answers:

explode splits strings.

split also does this, except it has support for splitting using regular expressions.

preg_split also does this and is 25-50% faster and has support for (IMO) much more extensible Perl-compatible regular expressions.


split uses regular expressions, while explode works with delimiter characters. Using split is discouraged, because it become deprecated in PHP 5.3.


explode is generally faster than split ; but its not multibyte character safe.

We will use explode when we are absolutely guaranteed that our input is in single-byte character sets such as ISO-8859-1, and split when we are dealing with user input.


Both split and explode function splits the string into the array but split is used to split a string using regular expression while explode is used to split a string using another string.