利用PHP解析IATA航班计划SSIM文件
随风飘扬 学习 2020年09月26日13:38 1456
今天接到需求要对SSIM文件进行解析,于是根据IATA提供的SSIM文件标准使用PHP的sscanf函数进行解析。
今天接到需求要对SSIM文件进行解析,于是根据IATA提供的SSIM文件标准使用PHP的sscanf函数进行解析。
虎m泰dl克iumc新fezaw闻rtudo网bp版权所有,请勿未授权转载!!!
<?php function parseSSIM() { $_ssim = file_get_contents('DEMBC.SSIM-MF.201013223500.txt'); $ssim = str_replace(' ', '*', $_ssim); $content = explode("\n3", $ssim); unset($_ssim, $ssim, $content[0]); foreach ($content as $flight) { $flightData = explode("\n", $flight); $rec = array(); sscanf('3' . $flightData[0], "%1s%1s%3s%4s%2s%2s%1s%7s%7s%7s%1s%3s%4s%4s%5s%2s%3s%4s%4s%5s%2s%3s%20s%5s%10s%9s%2s%6s%1s%3s%3s%3s%3s%4s%1s%1s%1s%1s%1s%11s%1s%11s%20s%2s", $rec['recordType'], $rec['operationalSuffix'], $rec['airline'], $rec['flightNumber'], $rec['itineraryVariation'], $rec['legSequenceNumber'], $rec['serviceType'], $rec['operationFrom'], $rec['operationTo'], $rec['operationDays'], $rec['frequencyRate'], $rec['departureStation'], $rec['passengerSTD'], $rec['STD'], $rec['deptureUTC'], $rec['departureTerminal'], $rec['arrivalStation'], $rec['STA'], $rec['passengerSTA'], $rec['arrivalUTC'], $rec['arrivalTerminal'], $rec['aircraftType'], $rec['PRBD'], $rec['PRBM'], $rec['mealSeviceNote'], $rec['jointOperationAirline'], $rec['MCT'], $rec['spare'], $rec['itineraryVariationOverflow'], $rec['aircraftOwner'], $rec['cockpitCrewEmployer'], $rec['cabinCrewEmployer'], $rec['airlineDesignator'], $rec['flightNumber2'], $rec['aircraftRotation'], $rec['operationalSuffix2'], $rec['spare2'], $rec['flightTransitLayover'], $rec['codeshare'], $rec['trafficRestrictionCode'], $rec['trafficRestrictionCodeLeg'], $rec['spare3'], $rec['aircraftConfiguration'], $rec['dateVariation']); $isCodeshare = false; foreach ($flightData as $info) { $type = array(); sscanf($info, "%1s%1s%3s%4s%2s%2s%1s%13s%1s%1s%1s%3s%3s%3s%155s", $type['recordType'], $type['operationalSuffix'], $type['airline'], $type['flightNumber'], $type['itineraryVariation'], $type['legSequenceNumber'], $type['serviceType'], $type['spare'], $type['itineraryVariationOverflow'], $type['boardPoint'], $type['offPoint'], $type['dataElement'], $type['departureStation'], $type['arrivalStation'], $type['data']); if ($type['dataElement'] === '010' || $type['dataElement'] === '050') { $isCodeshare = true; } $rec['info'][] = $type; } if ($isCodeshare) $data[] = $rec; unset($rec, $flightData); } unset($info, $flight, $content); return $data; } ?>
Erklärung: Alle auf dieser Website wiedergegebenen Artikel /Zeichnungen dienen dem Zweck, mehr Informationen zu übermitteln und die Diskussion zu erleichtern, was nicht bedeutet, dass die Website, der Host und der Veranstalter mit ihren Meinungen einverstanden sind oder die Authentizität ihrer Inhalte bestätigen. Der Inhalt der Artikel dient nur als Referenz. Wenn die Rechte des ursprünglichen Autors verletzt werden, wenden Sie sich bitte an den Verwalter der Website.
Liste der Kommentare
-
Keine Daten