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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -