本文實(shí)例講述了php從csv文件讀取數(shù)據(jù)并輸出到網(wǎng)頁的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:
<?php$fp = fopen('sample.csv','r') or die("can't open file");print "<table>/n";while($csv_line = fgetcsv($fp)) { print '<tr>'; for ($i = 0, $j = count($csv_line); $i < $j; $i++) { print '<td>'.htmlentities($csv_line[$i]).'</td>'; } print "</tr>/n";}print '</table>/n';fclose($fp) or die("can't close file");?>希望本文所述對(duì)大家的php程序設(shè)計(jì)有所幫助。
新聞熱點(diǎn)
疑難解答