refiking Posted September 26, 2009 Share Posted September 26, 2009 What I did was create an array of arrays and I need to enter each array as a row in a csv file. How can I go about doing that? It looks like this: $filename = 'export.csv'; $csv = array($allarrays); print_r($csv); // Looks like this: Array ( [0] => array("1","2"), array("6","2"), array("19,"5")) Quote Link to comment https://forums.phpfreaks.com/topic/175582-solved-create-a-csv-from-array/ Share on other sites More sharing options...
redarrow Posted September 26, 2009 Share Posted September 26, 2009 read this please fgetcsv might help? http://uk2.php.net/manual/en/function.fgetcsv.php Quote Link to comment https://forums.phpfreaks.com/topic/175582-solved-create-a-csv-from-array/#findComment-925235 Share on other sites More sharing options...
refiking Posted September 26, 2009 Author Share Posted September 26, 2009 I don't need to read a csv file. I need to create one. Quote Link to comment https://forums.phpfreaks.com/topic/175582-solved-create-a-csv-from-array/#findComment-925241 Share on other sites More sharing options...
redarrow Posted September 26, 2009 Share Posted September 26, 2009 normal way. now add your array info? <?php $myFile = "testFile.csv"; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = "one, two, three, four"; fwrite($fh, $stringData); fclose($fh); ?> Quote Link to comment https://forums.phpfreaks.com/topic/175582-solved-create-a-csv-from-array/#findComment-925244 Share on other sites More sharing options...
Philip Posted September 26, 2009 Share Posted September 26, 2009 read this please fgetcsv might help? http://uk2.php.net/manual/en/function.fgetcsv.php Close.... fputcsv Quote Link to comment https://forums.phpfreaks.com/topic/175582-solved-create-a-csv-from-array/#findComment-925253 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.