Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix the error with split() in php? [duplicate]

Tags:

php

How to fix this error.

Fatal error: Uncaught Error: Call to undefined function split() in /home/kmusi/public_html/base.php(725) : eval()'d code:9 Stack trace: #0 /home/kmusi/public_html/base.php(725) : eval()'d code(74): gregorian_to_jalaliq2a('1519984652') #1 /home/kmusi/public_html/base.php(761): when_to_html_override_1_in_gregorian2jalali_overrides_php('1519984652', '7') #2 /home/kmusi/public_html/base.php(822): call('when_to_html...', Array) #3 /home/kmusi/public_html/app/format.php(780): call_override('when_to_html', Array) #4 /home/kmusi/public_html/app/format.php(581): when_to_html('1519984652', '7') #5 /home/kmusi/public_html/app/format.php(826): post_html_fields(Array, 1, NULL, Array, NULL, Array) #6 /home/kmusi/public_html/app/format.php(986): other_to_q_html_fields(Array, 1, NULL, Array, NULL, Array) #7 /home/kmusi/public_html/app/list.p in /home/kmusi/public_html/base.php(725) : eval()'d code on line 9

like image 608
Akshay Kumar Avatar asked Nov 24 '18 02:11

Akshay Kumar


2 Answers

The split() function was removed in PHP 7. You can replace it with preg_split() or explode() function depending on the circumstances.

like image 100
Igor Carvalho Avatar answered Oct 20 '22 19:10

Igor Carvalho


Replace split() with explode()

$string = "a, b, c";
$array = explode(", ", $string);

It will give you array with 3 values in it.

split was deprecated in previous version of php but I think in php 7 it is removed so this is why it is saying undefined.

like image 36
Akhilesh Avatar answered Oct 20 '22 19:10

Akhilesh