{<?php
$out = file_get_contents('a3.log');
$delimiter = '#';
$startTag = 'Charge';
$endTag = 'NAtoms';
$regex = $delimiter . preg_quote($startTag, $delimiter)
. '(.*?)'
. preg_quote($endTag, $delimiter)
. $delimiter
. 's';
preg_match($regex,$out,$matches);
$match = $matches[0]."<br>";
echo $match."<br>";
?>
}
The file a3.log contain details like
Charge
6 4.39331 -0.36529 0.08491
6 1.60148 0.52177 -0.08236
6 4.0146 0.93715 -0.43575
6 3.28139 -1.1903 0.52189
6 1.9762 -0.77507 0.44518
6 2.71 1.35164 -0.51025
8 5.59201 -0.74722 0.15251
8 0.39622 0.90313 -0.16438
1 4.82888 1.57772 -0.77068
1 3.53221 -2.17174 0.92114
1 1.16487 -1.41898 0.78213
1 2.45473 2.33299 -0.90721
6 -3.24638 -1.04733 -0.60259
6 -2.62068 0.05335 -0.01331
7 -4.56997 -1.24972 -0.61786
6 -3.43634 1.00395 0.59709
6 -5.32808 -0.32334 -0.02513
NAtoms
And output I expect is just like this.
But output I got after running above code is like
Charge 6 4.39331 -0.36529 0.08491 6 1.60148 0.52177 -0.08236 6 4.0146
0.93715 -0.43575 6 3.28139 -1.1903 0.52189 6 1.9762 -0.77507 0.44518 6
2.71 1.35164 -0.51025 8 5.59201 -0.74722 0.15251 8 0.39622 0.90313
-0.16438 1 4.82888 1.57772 -0.77068 1 3.53221 -2.17174 0.92114 1 1.16487
-1.41898 0.78213 1 2.45473 2.33299 -0.90721 6 -3.24638 -1.04733 -0.60259
6 -2.62068 0.05335 -0.01331 7 -4.56997 -1.24972 -0.61786 6 -3.43634
1.00395 0.59709 6 -5.32808 -0.32334 -0.02513 6 -4.81776 0.81748 0.59417 1
-2.64561 -1.81055 -1.09513 1 -1.53556 0.17446 -0.03037 1 -2.98949 1.87809
1.06402 1 -6.4037 -0.50137 -0.04556 1 -5.48881 1.53609 1.05843w NAtoms
how can I get output in new line just shown above