I have 2 Json PHP URL and need to merge into 1.
1st Json PHP URL - completehouse.php
[
{
"G": "7TH DIVISION",
"G1": "2031892",
"DOOR": "8907",
"AA": "81",
"AI": "8745524"
},
{
"G": "8TH DIVISION",
"G1": "4526892",
"DOOR": "8877",
"AA": "85",
"AI": "8759544"
}
]
2nd Json PHP URL - completeflat.php
{
"Error": "",
"ErrorCode": 0,
"Guid": "",
"Id": 0,
"Success": true,
"Value": [
{
"G": "6TH DIVISION",
"G1": "6058974",
"DOOR": "1245",
"AA": "67",
"AI": "6872145"
},
{
"G": "5TH DIVISION",
"G1": "5891211",
"DOOR": "1246",
"AA": "68",
"AI": "5100214"
}
]
}
What I need is to merge these 2 file and get in completebuilding.php
Desired Output
{
"Error": "",
"ErrorCode": 0,
"Guid": "",
"Id": 0,
"Success": true,
"Value": [
{
"G": "6TH DIVISION",
"G1": "6058974",
"DOOR": "1245",
"AA": "67",
"AI": "6872145"
},
{
"G": "5TH DIVISION",
"G1": "5891211",
"DOOR": "1246",
"AA": "68",
"AI": "5100214"
},
{
"G": "7TH DIVISION",
"G1": "2031892",
"DOOR": "8907",
"AA": "81",
"AI": "8745524"
},
{
"G": "8TH DIVISION",
"G1": "4526892",
"DOOR": "8877",
"AA": "85",
"AI": "8759544"
}
]
}
Currently I am using following code in completebuilding.php :
<?php
$user[] = json_decode(file_get_contents("completehouse.php"), true);
$user[] = json_decode(file_get_contents("completeflat.php"), true);
$json_merge = json_encode($user);
header('Content-Type: application/json');
echo $json_merge;
?>
But not getting desired output instead I getting different. Help me to save my time from manual merge.
$completeFlat['Value'] = array_merge($completeFlat['Value'], $completeHouse);