PHP Script to convert .CSV files to .XML

后端 未结 4 1945
抹茶落季
抹茶落季 2021-01-02 08:30

Just wondering if anyone can point me in the direction of some tips / a script that will help me create an XML from an original CSV File, using PHP.

Cheers

4条回答
  •  执念已碎
    2021-01-02 09:08

    There are a number of sites out there that will do it for you.

    If this is going to be a regular process rather than a one-time thing it may be ideal to just parse the CSV and output the XML yourself:

    $csv = file("path/to/csv.csv");
    
    foreach($csv as $line)
    {
        $data = explode(",", $line);
        echo "".$data[0]."";
        //etc...
    }
    

    Look up PHP's file and string functions.

提交回复
热议问题