Posted by Anonymous Thu 7th Dec 2006 22:41 - Syntax is PHP - 50 viewsRun this post in the PHP shell
Download | New Post | Modify | Hide line numbers
PHP parser reported no syntax errors in this post!
  1.  
  2.     header('Content-type: text/plain');
  3.     $search_queries = initArray();
  4.     $query = $_GET['query'];
  5.     $results = search($search_queries, $query);
  6.     sendResults($query,$results);
  7.  
  8. function search($search_queries, $query) {
  9.     if (strlen($query) == 0)
  10.         return;
  11.  
  12.     $query = strtolower($query);
  13.  
  14.     $firstChar = 0;
  15.  
  16.     if (!preg_match('/[0-9a-z]/',$firstChar,$matches))
  17.         return;
  18.  
  19.         $charQueries = $search_queries[$firstChar];
  20.  
  21.     $results = array();
  22.  
  23.     for($i = 0; $i < count($charQueries); $i++) {
  24. if (strcasecmp(substr($charQueries[$i],1,strlen($query)),$query) == 0)
  25.  
  26.             $results[] = $charQueries[$i];
  27.     }
  28.  
  29.     return $results;
  30. }
  31.  
  32. function sendResults($query,$results) {
  33.     for ($i = 0; $i < count($results); $i++)
  34.         print "$results[$i]\n";
  35. }
  36.  
  37. function initArray() {
  38.     return array(
  39.     '0' => array(
  40. "The Ant Bully",
  41. "The Dog Island",
  42. "The Dog Island: Hitotsu no Hana no Monogatari",
  43. "The Grim Adventures of Billy & Mandy",
  44. "The Last Ninja",
  45. "The Legend of Zelda",
  46. "The Legend of Zelda: Twilight Princess",
  47. "The Sims",
  48. )
  49.     );
  50. }
  51. ?>

PermaLink to this entry https://pastebin.co.uk/7178
Posted by Anonymous Thu 7th Dec 2006 22:41 - Syntax is PHP - 50 viewsRun this post in the PHP shell
Download | New Post | Modify | Hide line numbers