I want to create MD array from numbers like below to send as JSON
OrderStatus Counts
Shipped 3
Pending 5
Final output should be,
[{order_status: "Shipped", Counts: 3}, {order_status: "Pending", Counts: 5} ]
Currently i am able to send only 1 row with this,
$orderTable[] = array(
'order_status' => 'Shipped',
'Counts' => 3);
How can i send two values as Json array?
You can create your array like this:
$orderTable = [
[
'order_status' => 'Shipped',
'Counts' => 3
],
[
'order_status' => 'Pending',
'Counts' => 5
]
];
$json = json_encode($orderTable);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.