I've a litle probleme with my loop. I've to do a while loop because i encode really big files. But if I encode row per row I create every time a new JSON Object.
So Now I've this output.
[
[
"some logs and soo with informations ",
"00:59:59",
"the pure logssdf"
]
][
[
"some logs and soo with informations ",
"00:59:52",
"the pure logssdf"
]
]
But I need something like this:
[
{
"some logs and soo with informations ",
"00:59:52",
"the pure logssdf"
},{
"some logs and soo with informations ",
"00:59:52",
"the pure logssdf"
}
]
And with this code I create this JSON-File:
$jsonFile = fopen('JSONLogs/' . $generatedName, "w");
$handle = @fopen($PATHTOLOG, "r");
if ($handle) {
while (($buffer = fgets($handle, 4096)) !== false) {
$pattern = '/^\w+\s+\d+\s('. preg_quote($SelectedTime) .':\d+.\d+).\d+.\d+\s(.+)/im';
if (preg_match_all($pattern, $buffer, $matches, PREG_SET_ORDER)) {
fwrite($jsonFile, json_encode($matches, JSON_PRETTY_PRINT));
}
else {
}
}
//var_dump($decodeData);
}
fclose($handle);
fclose($jsonFile);