I want to get some string in text file and divide then converting to JSON file this is my text file, data.txt
"5 minute input rate 134000 bits/sec, 164 packets/sec
5 minute output rate 1320000 bits/sec, 150 packets/sec"
I want get a string to array and make a JSON file maybe like this:
$time= "5 minute "
$input= "input rate 134000 bits/sec"
$output= "output rate 1320000 bits/sec"
$array[koneksi]= json_decode('[.".$time.":".$input.]');
this is my code in PHP
<?php
$lines = file('var/www/datakom/data.txt');
$title = 'data';
foreach ($lines as $line_num => $line) {
echo htmlspecialchars($line) . "<br />
"; }
?>
Please help me. thanks a lot