Is it possible to convert a coma separated string to a csv file in php?
str = "apple, orange, banana, lychee, grapes, pineapple, strawberry, mango";
Is it possible to convert a coma separated string to a csv file in php?
str = "apple, orange, banana, lychee, grapes, pineapple, strawberry, mango";
Have you tried this?
$str = "apple, orange, banana, lychee, grapes, pineapple, strawberry, mango";
$data = str_getcsv($str);
print_r($data);
To save $data to a file you can use fputcsv
//Open file
$fp = fopen('file.csv', 'w');
//Add $data to file
fputcsv($fp, $data);
//Close file.
fclose($fp);