【发布时间】:2011-01-28 16:21:24
【问题描述】:
我正在编写一个脚本来将产品导出到 Google Base...问题是,当我使用以下代码时,in stock 会输出为 "in stock" 而 Google 无法识别它,它只会在没有引号。我不知道在不包含引号的情况下如何做到这一点。
$row = array(
'new',
$product->getSku().'-'.$vehicle->getId(),
'https://www.domain.com/vehicles/'.str_replace(' ', '-', $make->getName()).'/'.str_replace(' ', '-', $model->getName()).'/'.$year.'/'.$product->getId(),
$this->tru->config->get('root.cdn.url').'-products/'.$product->getPicture(),
$product->getSellPrice(),
$title,
$year,
'in stock',
$product->getFCCID(),
'Visa,Mastercard,Discover,AmericanExpress',
'US::Ground:4.95,CA::Ground:28.95',
'small',
'Vehicles & Parts > Automotive Locking Systems > Remote Keyless Systems'
);
fputcsv($output, $row, $seperatorValue);
【问题讨论】:
-
$seperatorValue 的值是多少?如果你在 $row 数组中使用双引号而不是单引号会发生什么?
-
$seperatorValue = chr(9); - 它转义双引号
-
? chr(9) 这不是空格吗? echo "字符:|".chr(9)."|\n";