query($sql); $rowset = $rs->fetchAll(PDO::FETCH_ASSOC); foreach ($rowset as $v) { $list[] = array('id'=>$v['id'],'name'=>$v['name'],'id_type'=>$v['id_type'],'id_num'=>$v['id_num']); } if($rowset){ echo json_encode(array('code'=>'0','info'=>'0','list'=>$list)); }else{ echo json_encode(array('code'=>'0','info'=>$rs,'list'=>array())); }