How can I check if a value is already in an array?

How to search any value in an array. I want to search the value is parent in an array or not.

array_search() is what your looking for

Failing that, there’s always in_array() (:

in_array would be the best choice. find below the example.

<?php
$os = array(“Mac”, “NT”, “Irix”, “Linux”);
if (in_array(“Irix”, $os)) {
echo “Got Irix”;
}
if (in_array(“mac”, $os)) {
echo “Got mac”;
}
?>