我正在拉入一个 CSV,我想根据新行分解返回的字符串。
$quotes = file_get_contents('http://ca.finance.yahoo.com/d/quotes.csv?s=CLQ12.NYM+NGQ12.NYM+GCQ12.CMX+SIN12.CMX+HGN12.CMX+^DJI+^GSPC+^GSPTSE+^SPCDNX+X&f=nsc1');
给我:
"Crude Oil Aug 12","CLQ12.NYM",-3.10
"Natural Gas Aug 1","NGQ12.NYM",-0.165
"Gold Aug 12","GCQ12.CMX",-28.40
"Silver Jul 12","SIN12.CMX",-0.698
"Copper Jul 12","HGN12.CMX",-0.079
"S&P 500","^GSPC",-13.20
"S&P/TSX Composite","^GSPTSE",-156.71
"S&P/TSX Venture C","^SPCDNX",-18.29
"United States Ste","X",-0.37
然而,使用 $quotes = explode('\n', $quotes);
并没有做任何事情。返回每行数组的最简单方法是什么?