php從csv文件讀取數(shù)據(jù)并輸出到網(wǎng)頁的方法
來源:易賢網(wǎng) 閱讀:1602 次 日期:2015-03-19 14:22:30
溫馨提示:易賢網(wǎng)小編為您整理了“php從csv文件讀取數(shù)據(jù)并輸出到網(wǎng)頁的方法”,方便廣大網(wǎng)友查閱!

本文實例講述了php從csv文件讀取數(shù)據(jù)并輸出到網(wǎng)頁的方法。分享給大家供大家參考。具體實現(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");

?>

希望本文所述對大家的php程序設計有所幫助。

更多信息請查看IT技術專欄

更多信息請查看網(wǎng)絡編程
關于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點

版權所有:易賢網(wǎng)