剛剛把一個簡單的 php 範例改成我要的方式(跟原本的差不多啦!)


$fp = fopen ("sections.dat","r");

if (!$fp) {echo "

Unable to open remote file.

"; exit;}

while (!feof($fp)):
$line = fgets($fp, 2048);
$out = array($line);
list ($id, $name, $description, $language, $directory, $id_uplevel, $order, $hassubsection) = split ("\|", $out[0]);
echo "$id-$name-$description-$language-$directory-
$id_uplevel-$order-$hassubsection
\n";
$fp++;
endwhile;

fclose($fp);
?>

來源:
http://tw2.php.net/manual/en/function.fscanf.php

主要的程式碼:
split ("\|", $out[0])
用來切開欄位的函式
arrow
arrow
    全站熱搜

    tern 發表在 痞客邦 留言(0) 人氣()