Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Function split() is deprecated , preg_split(): No ending delimiter ',' found

I have a PHP script written 10 years ago. Now we moved the script to new server and it's not working. The line that has problem is:

$p_industry = split(',', $member['p_industry']);

The testing email receive this error message:

Function split() is deprecated .

I researched this website and then I replaced the script with

$p_industry = preg_split(',', $member['p_industry']);

Then the testing email receive this different error message:

preg_split(): No ending delimiter ',' found

When I change script to

$p_industry = explode(',', $member['p_industry']);

I did not receive any email for error message. But the script seems not working either. It seems not working in a way that it doesn't even send error message to testing email.

What should I change to the script? Can you give me specific answer?

like image 831
happybeauty Avatar asked May 19 '15 09:05

happybeauty


1 Answers

Preg_* functions has to have delimiters around pattern. I use ~.

$p_industry = preg_split('~,~', $member['p_industry']);
like image 144
pavel Avatar answered Oct 11 '22 19:10

pavel