Adding line breaks in a csv file
<p>I got a coma separated string. I need to convert this to an array and be able to save it as a csv file.</p>

<pre><code>$fp = fopen("abc.csv", "w");
$str = "FRUIT, STOCKS, TYPE\n lychee, instocks, B-type\n strawberry, N/A,A-type\n";

$data = str_getcsv($str);
fputcsv($fp, $data);
fclose($fp);
</code></pre>

<p>Currently it outputs the entire string as a single line.</p>

<p>Expected csv output:</p>

<pre><code>FRUIT,       STOCKS,      TYPE
lychee,      instocks,    B-type
strawberry,  N/A,         A-type
</code></pre>