Help me convert this array to object in php, below is my code
data: [
[
1638849672000,
0.0025
],
[
1638849732000,
0.0008
],
[
1638849792000,
0
],
[
1638849852000,
0
]
]
I want convert to Object
data: [
{
'time': 1638849670000,
'value': 0.0025,
},
{
'time': 1638849730000,
'value': 0.0008,
},
{
'time': 1638849790000,
'value': 0.0,
},
{
'time': 1638849850000,
'value: 0.0,
}
]
Here is my code
$newdata = [];
foreach ($data as $key => $value) {
foreach ($value as $vl) {
array_push($newdata, [
'time' => $vl,
'value' => $vl
]);
}
}
Help me convert this array to object in php, below is my code Thank you very much