0
私は最後の5行を読みたいtxtファイルを持っています。#は#で始まり#で終わります。 txtファイルは次のようになります。PHPでtxtファイルの最後の5行を読む方法#
#STA:00008;TM:04/30/2016,17:56:03;C:02;V:0.02;AD15:00000;AD16:00000;AD17:00000;AD18:00000;DI:001110;DO:0000;#
#STA:00008;TM:04/30/2016,17:56:32;C:03;V:0.02;AD15:00000;AD16:00000;AD17:00000;AD18:00000;DI:001110;DO:0000;#
#STA:00008;TM:04/30/2016,17:57:02;C:04;V:0.02;AD15:00000;AD16:00000;AD17:00000;AD18:00000;DI:001110;DO:0000;#
のコメント:
$file = file_get_contents("F:\RTU GSM\S220 GSM GPRS Remote Controller PC Configurator V2.1\profile\severtxt.txt");
$station = explode(";TM:",$file);
$keywords = preg_split("/;+/", $file);
print_r($keywords);
簡単でも、あなたが立ち往生している正規表現を必要としないのですか? – anubhava
$ file = file_get_contents( "F:\ RTU GSM \ S220 GSM GPRSリモートコントローラPCコンフィギュレータV2.1 \ profile \ severtxt.txt"); $ station = explode( "; TM:"、$ file); $ keywords = preg_split( "/; + /"、$ file); print_r($ keywords); –