Ruben Ruben - 1 year ago 124
PHP Question

CSV string change with php

Hi I would like to eliminate this sign " (quotation mark) in CSV file with PHP. I'm using this file with amchart, but with quotatnion mark chart doesn't work.

File is :





I'm using this code:

$records = array_map('str_getcsv', file('http://localhost/projekt/file.csv'));
$data =array();
foreach($records as $row){
if($row[0] != 'date'){
$data[] = array(
'date' => $row[0],
'open'=> $row[1],
'high'=> $row[2],
'low'=> $row[3],
'close'=> $row[4],
'column-5'=> $row[5],
'column-6'=> $row[6],
'column-7'=> $row[7],
'column-8'=> $row[8],
'column-9'=> $row[9],
'column-10'=> $row[10],
'column-11'=> $row[11],
'column-12'=> $row[12],
'column-13'=> $row[13],
$chartdata = json_encode($data);

$chartdata = str_replace('\/','/',$chartdata);

Answer Source

Why not just do a smaller change

 $records = array_map('str_getcsv',
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download