Space for google add

Find the element from the array that matches the given value using appropriate search function in PHP.

 


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.";

?>


Post a Comment

0 Comments