44. PHP Program to find a number existing given array of numbers or not.
How does this program work?
- In this program we are going to learn about how to find whether the given number is existing in array or not using PHP.
- In this program in_array() function is used to check whether the given value exists in an array or not in PHP.
Here is the code
<html>
<head>
<title>PHP Program To find number existing in given array or not</title>
</head>
<body>
<?php
$numbers = array(100, 65, 70, 87, 150, 55);
echo "Given Input : ";
foreach($numbers as $value)
{
echo $value . " ";
}
if (in_array("100", $numbers))
{
echo "100 is existing in array";
}
else
{
echo "100 is not existing in array";
}
return 0;
?>
</body>
</html>