Tagged: split

PHP: explode() or split()?

- by admin

Actually explode() isn’t the same as split().

The biggest difference is that explode() takes in parameters a delimiter to split by, while split() takes a regular expression. This means that explode() runs faster. And even more, the PHP documentation says that preg_split() is faster than split(), so really there isn’t much of a reason to use split() at all.

split() is not an alias of explode() while join() is an alias of implode().

And finally:

split() function has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged.

« All tags