note 22273 deleted from function.fgetcsv by cmb

From: Date: Sun, 16 Jun 2019 08:18:53 +0000
Subject: note 22273 deleted from function.fgetcsv by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-211279@lists.php.net to get a copy of this message
Note Submitter: joeldegan-AT-yahoo.com ---- function to parse multi arrays into csv data array in... array of array(datasets); first dataset = field names. usage: $toparse[0][0] = "field1"; $toparse[0][1] = "field2"; $toparse[1][0] = "value1"; $toparse[1][1] = "123123123"; // to see echo export_to_csv($toparse); <?php function export_to_csv($inarray){ while (list ($key1, $val1) = each ($inarray)) { while (list ($key, $val) = each ($val1)) { if (is_numeric($val)){ $sendback .= $val.","; }else{ $sendback .= "\"". $val ."\","; }//fi }//wend $sendback = substr($sendback, 0, -1); //chop last , $sendback .= "\n"; }//wend return ($sendback); }// end function ?> send the file to the client.. pretty simple. usage: send_file_to_client("data.csv",export_to_csv($data)); <?php function send_file_to_client($filename, $data){ header("Content-type: application/ofx"); header("Content-Disposition: attachment; filename=$filename"); echo $data; }; ?>

« previous php.notes (#211279) next »