"Function split() is deprecated" in PHP?

75,367

Solution 1

http://php.net/manual/en/function.split.php

From the manual

Warning This function has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged

Note:

As of PHP 5.3.0, the regex extension is deprecated in favor of the PCRE extension. Calling this function will issue an E_DEPRECATED notice. See the list of differences for help on converting to PCRE.

I guess you're supposed to use the alternative preg_split(). Or if you're not using a regex, just use explode

Solution 2

split has been replaced with explode, see http://php.net/explode for more information. Works the same as split, but split is 'deprecated' basically means that is a old function that shouldn't be used anymore, and is not likely to be in later versions of php.

Solution 3

Use following explode function:

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

This is the standard solution for this case. Its Perfectly working.

Solution 4

Ahh, the docs says about it. And the docs also say which functions should be used instead of this:

  1. preg_split
  2. explode
  3. str_split

Solution 5

Because the function has been deprecated? You can customize the error_reporting level to not log / display the depreciated errors. But it would be more prudent to just correct the issue (IE use explode instead for the simple split you are doing above.)

Share:
75,367
chrithccmc
Author by

chrithccmc

I'm Undergraduate at UCSC and I'm Sri Lankan.

Updated on September 08, 2021

Comments

  • chrithccmc
    chrithccmc over 2 years
    $stringText = "[TEST-1] test task 1 Created: 06/Apr/11  Updated: 06/Apr/11"; 
    $splitArray = split(" ",$stringText);
    

    Deprecated: Function split() is deprecated in C:\wamp\www\RSS.php on line 27

    Why this error happen ?

  • JohnP
    JohnP about 13 years
    Actually, split and explode are a bit different. explode doesn't support regex, so the replacement function would be preg_split