PHP explode \r and \n characters -
i have excel template used fill in data. export csv. 1 of fields contains new line character. when done on mac returns \r
instead or \n
when try explode text below:
$skillsets = explode("\r", $j['skillsets']); // works csv exported mac $skillsets = explode("\n", $j['skillsets']); // works csv exported win
is there way can check either of them , make sure explode works both \r
, \n
?
easiest use preg_split
:
$skillsets = preg_split('/(\r|\n)/', $j['skillsets']);
using regular expression not necessary, simple case, , need change 1 line of code.
Comments
Post a Comment