Location: PHPKode > scripts > slGrid > HTML/examples/support/livesearch.class.php
<?php
/**
 * Simple test class for doing fake livesearch
 *
 * @category   HTML
 * @package    AJAX
 * @author     Joshua Eichorn <hide@address.com>
 * @copyright  2005 Joshua Eichorn
 * @license    http://www.opensource.org/licenses/lgpl-license.php  LGPL
 * @version    Release: @package_version@
 * @link       http://pear.php.net/package/HTML_AJAX
 */
class livesearch {
	/**
	 * Items to search against
	 */
	var $livesearch = array(
		'Orange',
		'Apple',
		'Pear',
		'Banana',
		'Blueberry',
		'Fig',
		'Apricot',
		'Cherry',
		'Peach',
		'Plum',
		'Nectarine',
		'Boysenberry',
		'Cranberry',
		'Blackberry',
		'Clementine',
		'Grapefruit',
		'Lemon',
		'Lime',
		'Tangerine'
		);
	
	/**
	 * Perform a search
	 *
	 * @return array
	 */
	function search($input="") {
		$ret = array();
		if(empty($input)) {
			return $ret;
		}
		if (isset($_SESSION['sleep'])) {
			$ret['Latency Added'] = $_SESSION['sleep'];
		}
		foreach($this->livesearch as $key => $value) {
			if (stristr($value,$input)) {
				$ret[$key] = $value;
			}
		}
		return $ret;
	}
}
?>
Return current item: slGrid