PHP Programing language

adplus-dvertising
in_array() Function in PHP
Previous Home Next
adplus-dvertising

in_array()

The in_array() function searches an array for a specific value.

Syntax:
in_array(search,array,type)

In above syntax, "search" specifies the what to search for ,"array" specifies the array to search and "type" if the type parameter is set to TRUE, the in_array() function searches for the search-string and specific type in the array.

Example:

<?php
$fruits = array("Apple", "Banana", "Mango", "Orange");

if (in_array("Orange", $fruits))
   {
   echo "Fruit is found in the array";
   }
else
   {
   echo "Fruit is not found in the array";
   }
?>

Output:

Fruit is found in the array

Previous Home Next