Define an array. Find the element from the array that matches the given value using appropriate search function.
a2setb2.html
<html>
<body>
<form method="post" action="a2setb2.php">
Enter Number for search :
<input type='text' name='no' value=' '><br>
<input type='submit' name='submit' value='submit'>
</form>
</body>
</html>
a2setb2.php
<?php
$n=$_POST['no'];
$a=array(45,12,11,78,63,74);
if(!empty($n))
{
$b=array_search($n,$a);
if(array_search($n,$a))
{
echo "Element is found at position : $b";
}
else
echo "Element is not found";
}
else
echo "Please enter number for search.";
?>
0 Comments
If anyone has Doubts or suggestions please let me know