1 回答
TA贡献1798条经验 获得超7个赞
您需要Riskdtls进一步创建一个数组,$insured_data['QuotaDtls']['Riskdtls']如下所示
$insured_data['Authenticate'] = [
'WACode' => '0000',
];
$insured_data['QuotaDtls'] = [
'ProductType'=> 'Individual'
];
$insured_data['QuotaDtls']['Riskdtls'][] = [
"InsuredName"=> "Testone",
"entry2"=> "testdata2",
"entry3"=> "testdata3"
];
$json = json_encode($insured_data,JSON_PRETTY_PRINT) ;
printf("<pre>%s</pre>", $json);
通过使用json_encode函数将数组编码为 JSON 格式来实现所需的输出,最终输出如下:
{
"Authenticate": {
"WACode": "0000"
},
"QuotaDtls": {
"ProductType": "Individual",
"Riskdtls": [
{
"InsuredName": "Testone",
"entry2": "testdata2",
"entry3": "testdata3"
}
]
}
}
- 1 回答
- 0 关注
- 75 浏览
添加回答
举报