0

我对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>";
}
?>

我想将每一行变量添加到一个数组中......

即使有更好的方法,任何建议都会有所帮助。

4

1 回答 1

3

gah....为什么不简单

while($row = fgetcsv($fh)) {
    echo "<p>", implode(', ', $row), "</p>";
}

如果要将每一行存储在数组中,则

$data = array();
while($row = fgetcsv($fh)) {
    echo "<p>", implode(', ', $row), "</p>";
    $data[] = $row;
}
于 2013-03-04T18:30:04.500 回答