Deprecated: Function split() is deprecated. How to fix this statement?

php

Solution

Use `explode`:

$command = explode(" ", $tag[1]);

This is the standard solution for this case.

If you need to match on a regular expression (rather than something simple like a space), use `preg_split`. It's slower than `explode`, so there's no reason to use it unless you need a regex.

BTW to do the opposite (join array elements into a string), use `implode`.

Problem

I have the following statement which worked fine before PHP 5.3 using the split function: ``` $command = split (" ", $tag[1]); ``` After upgrading to PHP 5.3, I get the Deprecated warning: ``` Deprecated: Function split() is deprecated. ```

Original source

Related problems