zpairporttips.php

来自「zapatec suite 最新版 20070204,非常棒的ajax widg」· PHP 代码 · 共 59 行

PHP
59
字号
<?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 converterrequire_once('JSON.php');$objJsonConverter = new Services_JSON();// Include IATA location identifiersrequire_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 preciseif (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 resultecho $objJsonConverter->encode(array('tips' => $arrResult));?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?