query($sql); $rowset = $result->fetchAll(PDO::FETCH_ASSOC); $result->closeCursor(); foreach ($rowset as $v) { $prod_id = $v['prod_id']; $prod_name = $v['prod_name']; } $area = explode('-', $prod_name); $arr = array('prod_id' => $prod_id, 'startArea' => $area[0], 'endArea' => $area[1]); return json_encode($arr); } } } $prodId = "153052"; $lineInfo=new lineInfo(); $lineInfo->getLineInfo($prodId);