I have an array where i fetch from php with variable $allresults
:
Array
(
[1] => Array
(
[0] => 16/03/2018
[1] => Friday
[2] => 21.00
[3] => Friendly Match
[4] => Italy vs France
[5] => Truesports HD
)
[2] => Array
(
[0] => 17/03/2018
[1] => Saturday
[2] => 15.30
[3] => Friendly Match
[4] => Italy vs Pakistan
[5] => Truesports HD
)
[3] => Array
(
[0] => 17/03/2018
[1] => Saturday
[2] => 19.00
[3] => Friendly Match
[4] => Spain vs USA
[5] => Truesports
)
)
I have to convert it into json for other production use, so i use json_encode()
with this code below
echo json_encode($allresults, JSON_PRETTY_PRINT);
and the result become
[
"16\/03\/2018",
"Friday",
"21.00",
"Friendly Match",
"Italy vs France",
"Truesports HD"
],
[
"17\/03\/2018",
"Saturday",
"15.30",
"Friendly Match",
"Italy vs Pakistan",
"Truesports HD"
],
[
"17\/03\/2018",
"Saturday",
"19.00",
"Friendly Match",
"Spain vs USA",
"Truesports"
]
My point is how can i change this into something like this in my json.
[
"date":"17\/03\/2018",
"day":"Saturday",
"time":"19.00",
"type":"Friendly Match",
"value":"Spain vs USA",
"tv":"Truesports"
]
Should i change this from php array or i could change this from json file directly?