Saturday, September 3, 2016

Linear Search in PHP

A simple program that I wrote that will perform sequential or linear searching from a list of names in an array in PHP. The code is very short and easy to understand.


Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
 
My mobile number here in the Philippines is 09173084360
.



Program Listing


<html>
<body>
<center>
<h1>Linear Search in PHP</h1>
<?php
$people = array("Peter", "Joe", "Pedro", "Maria","Ana","Luisa");
if (isset($_POST['find']))
{
    $val=$_POST['search_me'];
    if (in_array($val, $people))
      {
          echo "Match found from the list.";
      }
    else
      {
          echo "Match not found in the list.";
      }
}
?>
<form method="post" action="linear.php">
    Enter a Name to be search <input type="text" name="search_me">
    <input type="submit" value="Search" name="find">
</form>
</center>
</body>
</html>

2 comments:

  1. nice work but try to allow user input before sorting is done

    ReplyDelete
  2. how much to hire you to do my final year project ?

    ReplyDelete