Aramex order tracking

Aramex AWB No. prefix . 'comments'; $history = $wpdb->get_results(" SELECT * FROM $table_perfixed WHERE `comment_post_ID` = $order_id AND `comment_type` LIKE 'order_note' "); $history_list = array(); foreach ($history as $shipment) { $history_list[] = $shipment->comment_content; } $last_track = ""; if (!empty($history_list)) { foreach ($history_list as $history) { $awbno = strstr($history, "- Order No", true); $awbno = trim($awbno, "AWB No."); if (isset($awbno)) { if ((int)$awbno) { $last_track = $awbno; break; } } $awbno = trim($awbno, "Aramex Shipment Return Order AWB No."); if (isset($awbno)) { if ((int)$awbno) { $last_track = $awbno; break; } } } } echo (!empty($last_track)) ? "". esc_attr($last_track) . "" : 'Not created'; ?>