我有一个从 DB 获取的数组。在这个项目中,我将我的数组转换为 csv 文件。但是每次我打开文件时,我都会得到双引号。我尝试使用 str_replace 和 preg_place 没有成功。我怎样才能删除引号
这是我的 csv 代码
$query = "SELECT t.transactiontime, t.restaurant_id, t.transactionid, t.cardid, emd.m_field_id_2, t.pricebefordiscount, t.menucard_cut
from transactions as t
left join exp_member_data AS emd ON (t.cardid-10000000 = emd.member_id) order by t.transactiontime desc limit 50";
$transactions_query = ee()->db->query($query);
$transactions_result = $transactions_query->result_array();
$transaction_array = array();
foreach ($transactions_result as $key)
{
$date = new DateTime($key['transactiontime']);
$newdate = $date->format('d.m.Y');
$transaction_array[] = array(
'transactiontime' => $newdate,
'restaurant_id' => $key['restaurant_id'],
'member' => $key['transactionid'] . " " . $key['m_field_id_2'],
'pricebefordiscount' => $key['pricebefordiscount']/100,
'menucard_cut' => $key['menucard_cut']
);
}
function outputCSV($data)
{
$outstream = fopen("php://output", 'w');
function __outputCSV(&$vals, $key, $filehandler)
{
fputcsv($filehandler, $vals, ';');
}
array_walk($data, '__outputCSV', $outstream);
fclose($outstream);
}
outputCSV($transaction_array);
我的输出
19.08.2013;47657;"12459 Abdullahi";60;
19.08.2013;47658;"12455 atima";30;