db->query($sql,array($labNo)); if (!$qry) { echo "ERR : " . $this->db->error()['message'] . " | " . $this->db->last_query(); exit; } $rows = $qry->result_array(); if (count($rows) == 0) { echo "ERR order not found!"; exit; } $z_content = $rows[0]["T_OnlineTxJsonGz"]; $content = gzinflate($z_content); $qrcode = $rows[0]["T_OnlineOrderT_OrderQrCode"]; $orderHeaderID = $rows[0]["T_OrderHeaderID"]; $json = json_decode($content,true); $orders = $json["order"]; $order = array_filter( $orders, function($o) use($qrcode) { if($o["T_OrderQrCode"] == $qrcode) { return true; } return false; }); if ( count($order) > 0 ) { echo $qrcode . " : $orderHeaderID : " . $order[0]["Test_PurposeName"] . "\n"; } } } ?>