Search code examples
phpfgetcsvfputcsv

fputcsv and fgetcsv


My code looks like this .. the o/p is a csv file with 4 values in ONE cell and so on in the FIRST column alone

Better versions of this code please . ASAP

foreach ($xml->xyz as $xyz) {  
$f = fopen('blahblahblah.csv', 'a') or die("can't open file");  
fputcsv($f, get_object_vars($lis),';','"');  

Solution

  • $f = fopen('blahblahblah.csv', 'a') or die("can't open file");    
    foreach ($xml->xyz as $xyz) fputcsv($f, get_object_vars($lis),';','"');
    fclose($f);
    

    It should be fine like this.