Loading…

How to check an element is exists in array or not in PHP?

With the help of in_array() function we can check any element is exists in array or not. It's return type is true when element is exists and false when an element is not exists in array.

Syntax

in_array(search,array,type)

Example

                                        

$array = array("Best", "Interview", "Questions");
if (in_array("Interview", $array))
{
echo "Element exists in array";
}
else
{
echo "Element not exists in array";
}

Suggest An Answer

No suggestions avaliable!

Latest post from PHP interview questions

Ask Question