Home > Archive > PHP DB > February 2007 > Re: [PHP-DB] csv problem.. read csv from var
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: [PHP-DB] csv problem.. read csv from var
|
|
| Niel Archer 2007-02-16, 3:58 am |
| hi
> 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.
Use
$arry = explode(',', $csv);
to separate the variable into an array, then process it using foreach as
before
Niel
| |
|
|
----- Original Message -----
From: "Niel Archer" <niel@catweasel.org>
To: <php-db@lists.php.net>
Sent: Friday, February 16, 2007 1:59 PM
Subject: Re: [PHP-DB] csv problem.. read csv from var
> hi
>
Faeces,VDRL,Anti -[color=darkred]
>
> Use
>
> $arry = explode(',', $csv);
>
=============================CODE=======
=============
<?
$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\"";
$arry = explode(',', $csv);
foreach($arry as $val){
$txt.= "=".$val . "<br />\n";
}
print $txt;
?>
=============================OUTPUT=====
==============
= 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"
> to separate the variable into an array, then process it using foreach as
> before
i'll already try that! fail.. it has tobe return 3 not ..10
thx for the reply
> Niel
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
| |
| Niel Archer 2007-02-16, 6:58 pm |
| Hi
sorry, I misunderstood your problem, it was not too clear to me as the
code you list shouldn't produce the output you supplied.
try this:
$array = explode(',', $csv);
print "<br>= " . $array[0] . "\n";
print "<br>= " . $array[1] . "\n";
for ($i = 2; $i < count($array); ++$i) {
$txt.= "<br />=" . $array[$i] . "\n";
}
print $txt;
Niel
| |
|
| nope.. u don't give me wrong code
----- Original Message -----
From: "Niel Archer" <niel@catweasel.org>
To: <php-db@lists.php.net>
Sent: Saturday, February 17, 2007 2:43 AM
Subject: Re: [PHP-DB] csv problem.. read csv from var
> Hi
>
> sorry, I misunderstood your problem, it was not too clear to me as the
> code you list shouldn't produce the output you supplied.
>
> try this:
>
> $array = explode(',', $csv);
>
> print "<br>= " . $array[0] . "\n";
> print "<br>= " . $array[1] . "\n";
>
> for ($i = 2; $i < count($array); ++$i) {
> $txt.= "<br />=" . $array[$i] . "\n";
> }
>
> print $txt;
>
>
> Niel
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
the code u mention before i tried to my code and it's not right..
thx for your support
|
|
|
|
|