backup
This commit is contained in:
51
ajax_workshop_1/gethint.php
Normal file
51
ajax_workshop_1/gethint.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
$a[] = "Anna";
|
||||
$a[] = "Brittany";
|
||||
$a[] = "Cinderella";
|
||||
$a[] = "Diana";
|
||||
$a[] = "Eva";
|
||||
$a[] = "Fiona";
|
||||
$a[] = "Gunda";
|
||||
$a[] = "Hege";
|
||||
$a[] = "Inga";
|
||||
$a[] = "Johanna";
|
||||
$a[] = "Kitty";
|
||||
$a[] = "Linda";
|
||||
$a[] = "Nina";
|
||||
$a[] = "Ophelia";
|
||||
$a[] = "Petunia";
|
||||
$a[] = "Amanda";
|
||||
$a[] = "Raquel";
|
||||
$a[] = "Cindy";
|
||||
$a[] = "Doris";
|
||||
$a[] = "Eve";
|
||||
$a[] = "Evita";
|
||||
$a[] = "Sunniva";
|
||||
$a[] = "Tove";
|
||||
$a[] = "Unni";
|
||||
$a[] = "Violet";
|
||||
$a[] = "Liza";
|
||||
$a[] = "Elizabeth";
|
||||
$a[] = "Ellen";
|
||||
$a[] = "Wenche";
|
||||
$a[] = "Vicky";
|
||||
|
||||
// get the q parameter, the text typed in, from URL
|
||||
$q = $_REQUEST["q"];
|
||||
$hint = "";
|
||||
// lookup all hints from array if $q is different from ""
|
||||
if ($q !== "") {
|
||||
$q = strtolower($q);
|
||||
$len=strlen($q);
|
||||
foreach($a as $name) {
|
||||
if (stristr($q, substr($name, 0, $len))) {
|
||||
if ($hint === "") {
|
||||
$hint = $name;
|
||||
} else {
|
||||
$hint .= ", $name";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Output "no suggestion" if no hint was found or output results
|
||||
echo $hint === "" ? "no suggestion" : $hint;
|
Reference in New Issue
Block a user