<?php
$response = '{
"status": 1,
"message": "Success",
"data": [
{
"order": {
"id_biling": "1",
"order_id": "A18",
"kd_bill": "001001202101200001",
"order_name": "Kita",
"amount": "20000"
},
"detail": [
{
"kd_bill": "001001202101200001",
"name": "Odading",
"id_item": "66",
"amount": "10000",
"subtot": "20000",
"jml": "2"
}
]
}
]
}';
$decoded_response = json_decode($response, true);
foreach($decoded_response['data'][0] as $key=>$value){
if ($key == 'detail'){
$decoded_response['data'][0]['order'][$key] = $value;
unset($decoded_response['data'][0][$key]);
}
}
echo json_encode($decoded_response);
preferences:
26.8 ms | 405 KiB | 5 Q