向txt文件循環寫入值:
代碼如下復制代碼$keys= range(1,999);
$file=fopen('key_11010000.txt',"w");
foreach($keysas$key){
fwrite($file,"$key\r\n");
}
fclose($file);
$f1=fopen('key_11010000.txt','r');
while(!feof($f1)){
$line=fgets($f1);
$line= trim($line);
$arr[] =$line;
}
$keys=array_filter($arr);
var_dump($keys);
按行讀取txt文檔數據:
代碼如下復制代碼$f1=fopen('key_11010000.txt','r');
while(!feof($f1)){
$line=fgets($f1);
$line= trim($line);
$arr[] =$line;
}
$keys=array_filter($arr);
var_dump($keys);
die;