lundi 10 septembre 2018

PHP Read TXT File

I have a txt file like this

SELL: num:1 rev(D:26048557 G:0) $D:150240888 $G:0 [08/10 18:05]
    - iybom01_10[100367586426880]
SELL: num:1 rev(D:26048557 G:0) $D:176289445 $G:0 [08/10 18:05]
    - iybom01_10[100367586426880]
BUY: num:7 pay(D:6716644 G:0) $D:169572801 $G:0 [08/10 18:08]
    + ipahp08_99_@ff[0]
    + ipahp08_99_@ff[0]
    + ipahp08_99_@ff[0]
    + ipahp08_99_@ff[0]
    + ipafp08_99_@ff[0]
    + ipasp04_99_@ff[0]
    + ipahp08_99_@ff[0]
BUY: num:5 pay(D:15784199 G:0) $D:153788602 $G:0 [08/10 18:09]
    + iharb35_747_@7ff55555[0]
    + iuarb35_0_@7ff55555[0]
    + ilarb35_0_@7ff55555[0]
    + igarb35_0_@7ff55555[0]
    + isarb35_0_@7ff55555[0]

I create a php script for get string "BUY" and "SELL" but i only can show the result like

Line 279: BUY: num:7 pay(D:6716644 G:0) $D:169572801 $G:0 [08/10 18:08] 

My php code like this

$lines = file('history/5.Log_History/Item/20180810/17/1696_175432.his');
$matches6 = preg_grep('/BUY/', $lines);
echo "BUY ITEM : " .count($matches6)." matches found.\n<br>";
foreach ($matches6 as $line => $contents) {
    echo "Line ".($line).": ".$contents."\n<br>";
}

I wanna get output like this

Line 279: BUY: num:7 pay(D:6716644 G:0) $D:169572801 $G:0 [08/10 18:08] 
    + iharb35_747_@7ff55555[0]
    + iuarb35_0_@7ff55555[0]
    + ilarb35_0_@7ff55555[0]
    + igarb35_0_@7ff55555[0]
    + isarb35_0_@7ff55555[0]

How I must edit my php script?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2NtXp21
via IFTTT

Aucun commentaire:

Enregistrer un commentaire