csv problem.. read csv from var
| From: | bedul | Date: | Fri, 16 Feb 2007 06:52:06 +0000 |
| Subject: | csv problem.. read csv from var | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-43082@lists.php.net to get a copy of this message | ||
i have problem with reading csv.. for i know the example script i get was
========================BASIC SCRIPT=================
$handle = fopen("hasillab.csv", "r");
$data2=$handle;
while($data = fgetcsv($handle, 1000, ",")){
foreach($data as $str)
$data2.="<br>= ".$str;
}
the result was:
==========================OUTPUT==========================
= A507257
= 3/2/2007
= Hematologi Lengkap,Cholesterol Total,LDL Cholesterol,Trigliserida,HDL
Cholesterol
hasillab.csv contain
A507257,3/2/2007,"Hematologi Lengkap,Cholesterol Total,LDL
Cholesterol,Trigliserida,HDL Cholesterol,Asam Urat,Gula Darah Puasa,Gula
Darah 2 Jam PP,Kreatinin,Ureum,Bilirubin Total,Alkali
Fosfatase,SGOT,SGPT,Urine Lengkap,Feses Rutin,Darah Samar Faeces,VDRL,Anti -
HBs,Total PSA,HBsAg,Anti - HCV Total"
the problem i have is.. how about the csv is a var
========================DATA===============
$csv="
A507257,3/2/2007,\"Hematologi Lengkap,Cholesterol Total,LDL
Cholesterol,Trigliserida,HDL Cholesterol,Asam Urat,Gula Darah Puasa,Gula
Darah 2 Jam PP,Kreatinin,Ureum,Bilirubin Total,Alkali
Fosfatase,SGOT,SGPT,Urine Lengkap,Feses Rutin,Darah Samar Faeces,VDRL,Anti -
HBs,Total PSA,HBsAg,Anti - HCV Total\"";
what should i do to make the ouput like above.
until now.. i try save the var into files then i use basic script to load it