Beny Bond Banjarnahor Beny Bond Banjarnahor - 3 years ago 184
MySQL Question

Reading specific value from a text file extensi .job

i have question, for get specific contain of file. i already get all data from many file .job extension, now i want to get data just in JobID rows so i can get all data JobID rows from many file .job, i want the output be "115518024" and more like the example. sorry my english. thanks

CODE GET DATA

foreach (glob("C://xampp/htdocs/LogMesinMutoh/*.job") as $file) {
$file_handle = fopen($file, "r");
while (!feof($file_handle)) {
$line = fgets($file_handle);
echo $line;
}
fclose($file_handle);
}


DATA FILE

[JobSetting]
File=D:\Shared\print\2017\september\26\Printing Ira\Cat Pattern EKA SITOMPUL 55X55.tif
PrintSetup=VJ-1624W_MURIM_HP100_4PASS.tps
RaPInfoFile=VJ-1624
JobID=115518024
WorkType=3
SourceSizeX=549.980530
SourceSizeY=549.980530
DestSizeX=549.980530
DestSizeY=549.980530

Answer Source

I assume $str is a file content

$str = "File=D:\Shared\print\2017\september\26\Printing Ira\Cat
Pattern EKA SITOMPUL 55X55.tif
PrintSetup=VJ-1624W_MURIM_HP100_4PASS.tps RaPInfoFile=VJ-1624
JobID=115518024 WorkType=3 SourceSizeX=549.980530
SourceSizeY=549.980530 DestSizeX=549.980530 DestSizeY=549.980530";


$regex = '/JobID=(\w+)/';

preg_match($regex, $str, $matches);

print_r($matches);

You will get your output at $matches[1]

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download