以下函數用來取出檔案中的數行存到陣列中。

PHP CODE:

<?php

function FetchFileLine($file,$count=0
){
 
$handle fopen($file"r"
);
 if (
$handle
) {
   while (!
feof($handle
)) {
     if(
$c>=$count
)
       break;

       
$lines[] = trim(fgets($handle4096
));
       
$c+=1
;
   }
   
fclose($handle
);
 }
  return  
$lines
;
}

?>


小檔案的做法:
PHP CODE:

<?php

function FetchFileLine($file,$count=0
){
$ffile($file
);
foreach(
$f as $k=>$v
){
if(
$k<$count
)
$f3[]=trim($v
);
}
return 
$f3
;
}
?>

arrow
arrow
    全站熱搜

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