Jump to content

selvakumar

New Members
  • Content Count

    5
  • Joined

  • Last visited

Community Reputation

0 Neutral

About selvakumar

  • Rank
    Newbie
  1. @Barand I am little bit curious that you shown the desired result. But when I used your logic in my code. It failed function generateCSV($data, $filename) { $fp = fopen("/local/myloc/populated/".$filename,"w+"); foreach ($data as $k => $v) { if ($k==0) { fputcsv($fp, array_keys($v)); } fprintf($fp, '"%s","%s","%s","%s","%s","%s"'."\n",array_values($v)); } fclose($fp); } I made only 2 changes. 1) path .. i don't think any issue 2) removed 3 dots before array_vales. If i keep that one, my
  2. @gw1500se Yes. I want. I really don't know why my tester insist this. There is no issue in values. Only in format double quotation
  3. Thanks gw1500se/Barand @gw1500se $fields[$k] = "\"".$v."\""; It doesn't provide desired result Date,time,Device,label,throughput_read,throughput_write """11/21/2020""","""00:00""","""audigysg36s6101""","""192905199.0""","""1742118968.0""","""11.073020990149""","""97.584""" """11/21/2020""","""00:05""","""audigysg36s6101""","""192914200.0""","""1742253920.0""","""11.072679922568""","""97.559""" @Barand I tried to apply your logic, but no luck . I am not sure why it failed to me function generateCSV($data, $filename) { $fp = = fopen("/local/myloc/popu
  4. Thank you very much gw1500se . I somewhat messed up the question. Actually i want to create a file on CSV format. Below is my logic to achieve my goal if($generate_csv){ generateCSV($custom[0]['details'], date('Y_m_d_')."check".".CSV", $detail_headers); } function generateCSV($data, $filename) { $file = fopen("/local/myloc/populated/".$filename,"w+"); $i = 0; foreach ($data as $line) { $fields = array(); foreach ($line as $k => $v) { $fields[$k] = $v; } if( $i === 0 ) { fputcsv($file, array_keys($fields) ); // First write the headers
  5. Team I tried to create csv output ( every value in double quotes) in my php using below function if($generate_csv){ generateCSV($custom[0]['details'], date('Y_m_d_')."check".".CSV", $detail_headers); } function generateCSV($data, $filename) { $file = fopen("/local/myloc/populated/".$filename,"w+"); $i = 0; foreach ($data as $line) { $fields = array(); foreach ($line as $k => $v) { $fields[$k] = $v; } if( $i === 0 ) { fputcsv($file, array_keys($fields) ); // First write the headers } fputcs
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.