我正在尝试获取文本区域的值并基于它创建一个 json 对象。
文本区域如下所示:
<textarea name="msisdn" wrap="physical">
51971855080
51971855081
51971855082
</textarea>
动态部分是“messId”和“destAddr”,其他部分将替换为从这样的表单接收到的 php 变量:
$str_obj_json='{
"method":"SUBMIT","params":{
"batchType":"submit",
"batchId":"'.$batch.'",
"origAddr":"550",
"origTon":2,
"userData":"'.$sms.'",
"submits":
[
{
"messId":"mess127_009",
"destAddr":"51971855080"},
{
"messId":"mess127_010",
"destAddr":"51971855081"},
{
"messId":"mess127_011",
"destAddr":"51971855082"},
]
}
}';
如何动态创建这部分?:
"submits":
[
{
"messId":"mess127_009",
"destAddr":"51971855080"},
{
"messId":"mess127_010",
"destAddr":"51971855081"},
{
"messId":"mess127_011",
"destAddr":"51971855082"},
]