lundi 12 février 2018

php clean up a string to be saved as .csv

My data is stored in a single string variables and all lines are broken using \n

"10, 20, jump\n 15, 16, walk\n, 30, 10, run\n"

How would I clean this up to saved as a .csv? because all functions that I find only take arrays and I receive the data as a string.

[Edit]

It's saved into a file but it has the wrong formatting when I open the file

$fileData = fopen('test.csv', "w");
fputs($fileData, fputcsv($stringData));
fclose($fileData);




Aucun commentaire:

Enregistrer un commentaire