有一个通过REST JSON发送的curl POST请求示例。Php Json数据格式
{"email": "[email protected]", "items": [{ "name": "api Name", "quantity": 10, "unit_price": 2}, { "name": "api 2", "quantity": "4", "unit_price": 3 }]
}
我该如何在PHP中对其进行格式化。
我曾尝试以下:
$data = array(
'email' => '[email protected]',
);
$data['items'] = array(
'name' => 'fruits', 'quantity' => 4,
'unit_price' => 7,
);
服务刚刚接受email
,而忽略items
。
该示例在'items'数组中包含两个对象,您的结构包含三个标量值。 – arkascha