我在尝试用 PHP 编写代码时遇到了麻烦:
{
"value": {
"board": [
{"name": "Abdul-Jabbar", "values": [38387, 1560, 24.6]},
{"name": "Karl Malone", "values": [36928, 1476, 25.0]},
{"name": "Michael Jordan", "values": [32292, 1072, 30.1]},
{"name": "W. Chamberlain", "values": [31419, 1045, 30.1]},
{"name": "Kobe Bryant", "values": [29484, 1161, 25.4]},
{"name": "Shaq O Neal", "values": [28596, 1207, 23.7]},
{"name": "Moses Malone", "values": [27409, 1329, 20.6]},
{"name": "Elvis Hayes", "values": [28313, 1303, 21.0]},
{"name": "H. Olajuwon", "values": [26946, 1238, 21.8]}
]
}
}
到目前为止,我有这个:
$cart = array();
foreach ($deliveries as $delivery) {
// get name of the message sent.
$msgFilter = array('id' => $delivery->messageId);
$message = array_pop($client->readMessages(array('pageNumber' => 1,
'includeContent' => false,
'filter' => $msgFilter))->return);
$cart[] = array(
"value" => array(
array(
"message" => $message->name
),
array(
"value" => $delivery->revenue
)
)
);
}
$postData = json_encode($cart);
我不知道如何将值和板包装在数组周围?!?