$quote_array = explode("\n", $raw_quote_data);
echo "<table>";
echo "<th>Name</th> <th>Stock Quote</th> <th>Change";
foreach ($quote_array as $quote_value) {
echo "<tr>";
$quote = explode(",", $quote_value);
$symbol = str_replace("\"", "", $quote[0]);
**$value = $quote[1];**
**$change = $quote[2];**
echo "<td>$symbol</td> <td>$value</td> <td>$change</td>";
echo "</tr>";
}
echo "</table>";
}
错误告诉我可以在第32和33行找到未定义的偏移,但我似乎无法解决问题。我在某处有额外的引号吗?
$ raw_quote_data以此格式显示为.csv:
NASDAQComposite 3229.57 7.2
纽约证券交易所100指数5220.187 11.626
富时100 6439.16 11.52
$ quote_array的var_dump如下所示:array (size=4) 0 => string '"NASDAQComposite",3228.62,+6.25' (length=32) 1 => string '"NYSEINTL100INDEX",5220.348,+11.788' (length=36) 2 => string '"FTSE 100",6439.16,+11.52' (length=26) 3 => string '' (length=0)