[ Mini Kiebo ]
Server: Windows NT DESKTOP-5B8S0D4 6.2 build 9200 (Windows 8 Professional Edition) i586
Path:
D:
/
xampp182
/
htdocs
/
simpeg
/
zapatec
/
zpautocomplete
/
zpautocomplete
/
demo
/
[
Home
]
File: zpairporttips.php
<?php /** * Takes in keyword and sends back list of airports containing this keyword in * the city name or airport name or IATA location identifier. * * Part of Zapatec Travel application. * * Copyright (c) 2004-2006 by Zapatec, Inc. * http://www.zapatec.com * 1700 MLK Way, Berkeley, California, * 94709, U.S.A. * All rights reserved. */ /* $Id: zpairporttips.php 7323 2007-06-01 21:05:51Z alex $ */ // JSON converter require_once('JSON.php'); $objJsonConverter = new Services_JSON(); // Include IATA location identifiers require_once('zpairports.php'); // Will hold result $arrResult = array(); // Get keyword $strKeyword = isset($_GET['q']) ? strtoupper($_GET['q']) : ''; // Keyword must contain at least 3 chars, otherwise result will not be precise if (strlen($strKeyword) > 2) { // Search by IATA location identifier if (isset($ZP_AIRPORTS[$strKeyword])) { // Match array_push($arrResult, array( 'code' => $strKeyword, 'city' => $ZP_AIRPORTS[$strKeyword]['city'], 'name' => $ZP_AIRPORTS[$strKeyword]['name'] )); } // Search by city and name foreach ($ZP_AIRPORTS as $strKey => $objValue) { if ((preg_match("/^$strKeyword/i", $objValue['city']) || preg_match("/^$strKeyword/i", $objValue['name'])) && $strKey != $strKeyword) { // Match array_push($arrResult, array( 'code' => $strKey, 'city' => $objValue['city'], 'name' => $objValue['name'] )); } } } // Return result echo $objJsonConverter->encode(array('tips' => $arrResult)); ?>