Code:
<!DOCTYPE html><html>
<body>
<center>
<h1>Linear search in array</h1>
<?php
$people = array("Peter", "Joe", "Glenn", "Cleveland");
if (isset($_POST['find']))
{
$val=$_POST['srch'];
if (in_array($val, $people))
{
echo "Match found";
}
else
{
echo "Match not found";
}
}
?>
<form method="post" action="index.php">
Search in array: <input type="text" name="srch">
<input type="submit" value="Search" name="find">
</form>
</center>
</body>
</html>
No comments:
Post a Comment