返回数据Json: { “code”: 200, ”msg”: ”成功”, ”departmentlist”: [ { "id": "32", "name": "软件部" } ], ”userlist”: [ { "id": "11", "headiconurl": "用户头像地址", "truename": "姓名", "positionname": "职位" } ] }
php接口代码
前面的查询符合条件sql语句已省略. $arr=array(); $arr[‘code‘]=200; $arr[‘msg‘]=‘成功‘; $arr[‘departmentlist‘][]=array( ‘id‘=>$dept[‘id‘], ‘name‘=>$dept[‘name‘], ); foreach($deptmember as $key=>$val) { $arr[‘userlist‘][] = array( ‘id‘ => $val[‘id‘], ‘headiconurl‘ => $val[‘face‘], ‘truename‘ => $val[‘name‘], ‘positionname‘ => $val[‘ranking‘], ); } echo json_encode($arr,true);
时间: 2024-11-03 22:38:58