Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

erorr function split() in php 7 in q2a 1.8

+1 vote
asked Mar 10 in Q2A Core by MR Arsha

How to fix this problem ? 

Fatal error: Uncaught Error: Call to undefined function split() in /home/ariapadw/public_html/ask/qa-include/qa-base.php(725) : eval()'d code:9 Stack trace: #0 /home/ariapadw/public_html/ask/qa-include/qa-base.php(725) : eval()'d code(74): gregorian_to_jalaliq2a('1519984652') #1 /home/ariapadw/public_html/ask/qa-include/qa-base.php(761): qa_when_to_html_override_1_in_gregorian2jalali_overrides_php('1519984652', '7') #2 /home/ariapadw/public_html/ask/qa-include/qa-base.php(822): qa_call('qa_when_to_html...', Array) #3 /home/ariapadw/public_html/ask/qa-include/app/format.php(780): qa_call_override('qa_when_to_html', Array) #4 /home/ariapadw/public_html/ask/qa-include/app/format.php(581): qa_when_to_html('1519984652', '7') #5 /home/ariapadw/public_html/ask/qa-include/app/format.php(826): qa_post_html_fields(Array, 1, NULL, Array, NULL, Array) #6 /home/ariapadw/public_html/ask/qa-include/app/format.php(986): qa_other_to_q_html_fields(Array, 1, NULL, Array, NULL, Array) #7 /home/ariapadw/public_html/ask/qa-include/app/q-list.p in /home/ariapadw/public_html/ask/qa-include/qa-base.php(725) : eval()'d code on line 9

commented Mar 11 by pupi1985
Seems to be an error with some "Jalali" plugin. Have you tried asking the developer for a fix?
commented Mar 18 by arsha
tnx - ok fix

1 Answer

+4 votes
answered Mar 17 by Scott
Best answer

The split function was removed in PHP 7. Can be replaced by preg_split or explode depending on the circumstances.

I'm guessing this is the plugin you're using? In which case you'll need to change line 9 of gregorian2jalali-overrides.php from this:

@list($g_y, $g_m, $g_d)=split('[,]',date("Y,m,d",$timestamp));

to this:

@list($g_y, $g_m, $g_d) = explode(',',date("Y,m,d",$timestamp));

Hope that helps. If you're able to report the issue (and fix) to the developer, please do.