1
我已經設法使用下面的代碼保存產品供稿的製表符分隔文件。不過,我提交的Feed要求字段不包含在引號中。有沒有辦法將這個文件保存在字段中不帶引號的地方。如何從php數組中導出不帶引號的製表符分隔txt文件
$feed[]=array('Item','Description','Category');
$feed[]=array('1-1','Words describing item 1, for example.','Top Category > SubCategory1');
$feed[]=array('1-2','Words describing item 2.','Top Category > SubCategory2');
header('Content-type: text/tab-separated-values');
header("Content-Disposition: attachment;filename=bingproductfeed.txt");
$f = fopen('php://output', 'a');
foreach ($feed as $fields) {
//$fields=str_replace('"','',$fields);
//$fields=trim($fields,'"');
fputcsv($f, $fields, "\t");
}
//Outputs:
//Item Description Category
//1-1 "Words describing item 1, for example." "Top Category > SubCategory1"
//1-2 "Words describing item 2." "Top Category > SubCategory2"
//I need:
//Item Description Category
//1-1 Words describing item 1, for example. Top Category > SubCategory1
//1-2 Words describing item 2. Top Category > SubCategory2
我試過修剪引號,並用空格替換它們,但沒有運氣。有沒有辦法做到這一點,所以我可以提交這個飼料沒有錯誤?
我想看看 「圈地」 ...... http://php.net/manual/en/function.fputcsv.php – dbinns66