You can take reference form below example to find the value in an array list using php in_array.
Suppose you have a list of Favorite List items (for example a list of colors names) and you want search your color is exist in list or not exist.
<?php
$GetColors = array("Green", "Red", "Blue", "Yellow","Pink");
/*$GetColors is a userdefine variable in which store all colors name.*/
/*Now suppose you want search blue colors in array list.*/
//put this query
if (in_array("Blue", $GetColors))
{
echo "success colors Found";
}
else
{
echo "fail colors Not Found";
}
?>
If Blue color exist in given array list then result will come "success colors Found";
0 Comment(s)