我对php很新,所以请原谅我的无知......:P
我有以下代码:
<?php
$fh = fopen("../filename.csv", "r");
while (list($siteid, $sitename, $scheduled, $arecords, $crons, $sslintf, $customip, $psccjobs, $odbc, $sitesize, $dbsize, $nfssize, $fasize, $siteclass, $dbexport, $chatver, $socintf, $sitemode, $mailboxes, $mailfiles, $oesmtp) = fgetcsv($fh, 1024, ";")) {
echo "<p>$siteid, $sitename, $scheduled, $arecords, $crons, $sslintf, $customip, $psccjobs, $odbc, $sitesize, $dbsize, $nfssize, $fasize, $siteclass, $dbexport, $chatver, $socintf, $sitemode, $mailboxes, $mailfiles, $oesmtp</p>";
}
?>
我想将每行变量添加到数组中......
即使有更好的方法,任何建议都会有所帮助。
答案 0 :(得分:3)
gah ....为什么不简单
while($row = fgetcsv($fh)) {
echo "<p>", implode(', ', $row), "</p>";
}
如果要将每一行存储在一个数组中,那么
$data = array();
while($row = fgetcsv($fh)) {
echo "<p>", implode(', ', $row), "</p>";
$data[] = $row;
}