in_array fonksiyonu

Php'de bir dizide aranan elemanın, dizide bulunup bulunmadığını nasıl anlarım?



<?php
$values 
= array("banana","apple","pear","banana");

$newvalue "pear";
if (
in_array($newvalue,$values)) {

echo "$newvalue is already in the array!";
}  
?>

pear is already in the array!  


<?php
$numbers 
range(1,10);

$checknumbers = array(1,20,10);
foreach(
$checknumbers as $isitthere) {
if(
in_array($isitthere,$numbers)) {

echo "The number $isitthere is in the numbers array"
} else { 
echo "The number $isitthere is NOT in the numbers array";
}
}
 

?>  
  
The number 1 is in the numbers array
The number 20 is NOT in the numbers array
The number 10 is in the numbers array