Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Function split() is deprecated" in PHP?

$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 ?

like image 781
chrithccmc Avatar asked Apr 18 '11 06:04

chrithccmc


People also ask

What is split function in PHP?

Definition and Usage. The split() function will divide a string into various elements, the boundaries of each element based on the occurrence of pattern in string.


2 Answers

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

like image 110
JohnP Avatar answered Oct 23 '22 12:10

JohnP


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.

like image 24
gnur Avatar answered Oct 23 '22 12:10

gnur