PHP split alternative?

PHP is telling me that split is deprecated, what's the alternative method I should use?


explode is an alternative. However, if you meant to split through a regular expression, the alternative is preg_split instead.


split is deprecated since it is part of the family of functions which make use of POSIX regular expressions; that entire family is deprecated in favour of the PCRE (preg_*) functions.

If you do not need the regular expression functionality, then explode is a very good choice (and would have been recommended over split even if that were not deprecated), if on the other hand you do need to use regular expressions then the PCRE alternate is simply preg_split.