Importing CSV that has line breaks within the actual fields

后端 未结 6 1966
挽巷
挽巷 2021-02-20 08:23

I am using PHP to import a CSV file, which originates from an excel spreadsheet. Some of the fields contain line breaks in them, so when I reopen the csv in excel / open office

6条回答
  •  执笔经年
    2021-02-20 08:54

    My solution is the following:

    nl2br(string);
    

    http://php.net/manual/en/function.nl2br.php

    Once you get to the individual cell (string) level, run it on the string and it will convert the linebreaks to html breaks for you.

提交回复
热议问题