file
(PHP3 , PHP4)
file --- 讀取檔案全部內容到陣列中
語法 :
array file(string filename [, int use_include_path])說明 :
與readfile( )相同,不同處在於此函式是傳回陣列,各個陣列的元素相當於檔案中的行數。新行(newline)依舊是附屬的。
如果你想要在include_path中搜尋檔案,你可以使用第二個參數並且將它設為"1"。
<?php
// get a web page into an array and print it out
$fcontents = file ('http://www.php.net');
while (list ($line_num, $line) = each ($fcontents)) {
echo "<b>Line $line_num:</b> " . htmlspecialchars ($line) . "<br>\n";
}
// get a web page into a string
$fcontents = join ('', file ('http://www.php.net'));
?>
參考 : readfile( ) fopen( ) popen( )