How to split a string on * and - in PHP?

SoymnGync

New Member
Inorder to split the string i have used the following code.\[code\]$string = "-sev*yes-sev1*no-sev2*yes";split('[-*]', $string).\[/code\]As split is deprecated, can you please suggest an alternative to split the string into an array. I have tried with explode, but it is not serving my purpose.The output should look like,\[code\]Array( [0] => sev [1] => yes [2] => sev1 [3] => no [4] => sev2 [5] => yes)\[/code\]Thank u all for ur responses..I tried \[code\]preg_split('[-*]', $string)\[/code\]. It has split has the string character wise. I have modified it to \[code\]preg_split('/[-*]/', $string)\[/code\]. It is working well. It would be great if you can explain me the difference.
 
Back
Top