PHP删除标题中的双引号

PHP删除标题中的双引号,php,css,csv,Php,Css,Csv,下面的代码从csv文件生成一个表 <?php $lines = file('graphdata/indicfortablevsprevious.csv'); foreach ($lines as $lineNum => $line) { $cellType = ($lineNum == 0 ? "th" : "td"); $tokens = str_getcsv($line); if ($lineNum == 0) echo

下面的代码从csv文件生成一个表

 <?php
      $lines = file('graphdata/indicfortablevsprevious.csv');  


      foreach ($lines as $lineNum => $line) {
    $cellType = ($lineNum == 0 ? "th" : "td");
    $tokens = str_getcsv($line);

    if ($lineNum == 0) echo "<thead>";
    if ($lineNum == 1) echo "<tbody>";

    echo "<tr id=\"tr" . $lineNum . "\">";

    echo "<" . $cellType . " style=\"width: 300px;\">" . trim($tokens[0]) . "</" . $cellType . ">";
    echo "<" . $cellType . " style=\"width: 100px;\">" . trim($tokens[1]) . "</" . $cellType . ">";
    echo "<" . $cellType . " style=\"width: 100px;\">" . trim($tokens[2]) . "</" . $cellType . ">";
    echo "<" . $cellType . " style=\"width: 100px;\">" . trim($tokens[3]) . "</" . $cellType . ">";
    echo "<" . $cellType . " style=\"width: 100px;\">" . trim($tokens[4]) . "</" . $cellType . ">";

    echo "</tr>";

    if ($lineNum == 0) echo "</thead>";
}

if (count($lines) > 1) echo "</tbody>";
    ?>


CSV中的第一个表头是双引号,php创建的表头也是双引号(奇怪的是,其他的表头不是)。有没有办法摆脱PHP创建的表中的双引号?

您是否尝试过使用
trim($str,“”);
这里
$str=第一个表的标题
。试试看,它可能对您有用。

这些引号的来源可能是csv文件本身吗?csv中的eHeader是:“itemname”、“n2015Survey”、“2015Survey”2014年调查,“差距与先前调查”仅“项目名称”在PHP表格中出现双引号。您能给我们展示一些csv原始数据吗?