- json_decode: documentation ( source)
- print_r: documentation ( source)
<?php
$json = '{
"metingen": [
{
"label": "06-06-2019 13:13:38",
"value": 25.21
},
{
"label": "06-06-2019 13:51:04",
"value": 27.69
},
{
"label": "06-06-2019 13:52:04",
"value": 27.69
},
{
"label": "06-06-2019 13:53:06",
"value": 27.61
}]}';
$jToArr = json_decode($json, true);
$res = [];
foreach($jToArr['metingen'] as $key => $value){
$res[] = ['x' => $value['label'], 'y' => $value['value']];
}
print_r($res);