1 回答
TA贡献1772条经验 获得超8个赞
输出...
"delivery_date": "2020-08-25"
{
无法实现,因此此代码将创建输出,其中包含送货和货车列表......
$output = [];
while( $result = $getorders->fetch(\PDO::FETCH_ASSOC)) {
if ( !isset($output[$result['delivery_date']]) ) {
$output[$result['delivery_date']]['date'] = $result['delivery_date'];
}
if ( !isset($output[$result['delivery_date']][$result['van_no']]) ) {
$output[$result['delivery_date']][$result['van_no']]['van']
= $result['van_no'];
}
$output[$result['delivery_date']]
[$result['van_no']][] = $result;
}
echo json_encode(array_values($output), JSON_PRETTY_PRINT);
这会给你一些类似...
[
{
"date": "2020-08-25",
"1": {
"van": 1,
"0": {
"delivery_date": "2020-08-25",
"van_no": 1,
- 1 回答
- 0 关注
- 117 浏览
添加回答
举报