當前位置:編程學習大全網 - 網站源碼 - php逐行讀取txt、csv並分頁

php逐行讀取txt、csv並分頁

$filename='a.txt';//文件名

$str=file_get_content($filename);//獲得內容

$arr=explode("\n",$str);//分行存入數組

foreach($arr as $row){//遍歷每行

$temp=explode(" ",$row);

//此時$temp[0]=前面的id號,$temp[1]=中文名,$temp[2]=後面的壹長串

//賦值吧

}

//explode是按字符分割string

//可以查查php手冊

//存回去用file_put_content

  • 上一篇:Vue和燒瓶之間的連接
  • 下一篇:遵循物理電流疊加定理中公式
  • copyright 2024編程學習大全網