<?php
header('Content-type: text/plain');
$search_queries = initArray();
$query = $_GET['query'];
$results = search($search_queries, $query);
sendResults($query,$results);
function search($search_queries, $query) {
if (strlen($query) == 0)
return;
$query = strtolower($query);
$firstChar = 0;
if (!preg_match('/[0-9a-z]/',$firstChar,$matches))
return;
$charQueries = $search_queries[$firstChar];
$results = array();
for($i = 0; $i < count($charQueries); $i++) {
if (strcasecmp(substr($charQueries[$i],0,strlen($query)),$query) == 0)
$results[] = $charQueries[$i];
}
return $results;
}
function sendResults($query,$results) {
for ($i = 0; $i < count($results); $i++)
print "$results[$i]\n";
}
function initArray() {
return array(
'0' => array(
"The Ant Bully",
"The Dog Island",
"The Dog Island: Hitotsu no Hana no Monogatari",
"The Grim Adventures of Billy & Mandy",
"The Last Ninja",
"The Legend of Zelda",
"The Legend of Zelda: Twilight Princess",
"The Sims",
)
);
}
?>
Time to create page: 0.047 seconds