I am using in_array to detect if a value is within a PHP array, my array looks like this...
$fruits = array("banana", "grape", "orange", "apple");
/* is grape in the array */
if (in_array('grape', $fruits)) {
echo 'Grape Detected';
} else {
echo 'Grape not detected';
}
I am trying to modify this so that it can also detect when the 'grape' is the only item in the array, so if the array looked like this...
$fruits = array("grape", "grape", "grape");
or...
$fruits = array("grape");
Then I could display a custom message, anyone have an example I can see?