Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. <?php
  2. // Array with names
  3. $a[] = "Anna";
  4. $a[] = "Brittany";
  5. $a[] = "Cinderella";
  6. $a[] = "Diana";
  7. $a[] = "Eva";
  8. $a[] = "Fiona";
  9. $a[] = "Gunda";
  10. $a[] = "Hege";
  11. $a[] = "Inga";
  12. $a[] = "Johanna";
  13. $a[] = "Kitty";
  14. $a[] = "Linda";
  15. $a[] = "Nina";
  16. $a[] = "Ophelia";
  17. $a[] = "Petunia";
  18. $a[] = "Amanda";
  19. $a[] = "Raquel";
  20. $a[] = "Cindy";
  21. $a[] = "Doris";
  22. $a[] = "Eve";
  23. $a[] = "Evita";
  24. $a[] = "Sunniva";
  25. $a[] = "Tove";
  26. $a[] = "Unni";
  27. $a[] = "Violet";
  28. $a[] = "Liza";
  29. $a[] = "Elizabeth";
  30. $a[] = "Ellen";
  31. $a[] = "Wenche";
  32. $a[] = "Vicky";
  33.  
  34. // get the q parameter from URL
  35. $q = $_REQUEST["q"];
  36.  
  37. $hint = "";
  38.  
  39. // lookup all hints from array if $q is different from ""
  40. if ($q !== "") {
  41. $q = strtolower($q);
  42. $len=strlen($q);
  43. foreach($a as $name) {
  44. if (stristr($q, substr($name, 0, $len))) {
  45. if ($hint === "") {
  46. $hint = $name;
  47. } else {
  48. $hint .= ", $name";
  49. }
  50. }
  51. }
  52. }
  53. // Output "no suggestion" if no hint was found or output correct values
  54. echo $hint === "" ? "no suggestion" : $hint;
  55. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement