045 - in_array (give result 0/1) both value same case = 1both value different case = search different value in array = Find Successfully string apple in the array .Finding string with integer (55) =1Finding string with integer (55) with strict mode = Find the array .
<?php
// 045 - in_array (give result 0/1)
echo "</br><span class='myheading'>045 - in_array (give result 0/1) </span></br>";
$food_045 = array('orange', 'banana', 'apple', 'grapes','55');
echo "</br>both value same case = " . in_array("apple", $food_045) ; // both value same
echo "</br>both value different case = " . in_array("Apple", $food_045) ; // value same ,different case
echo "</br>search different value in array = " . in_array("Lime", $food_045) ; // both value different
if (in_array("apple", $food_045)) { // using if
echo "</br>Find Successfully string apple in the array .</br>";
}else{
echo "Can't Find.</br>";
}
echo "Finding string with integer (55) =" . in_array(55, $food_045) ."</br>";
echo "Finding string with integer (55) with strict mode = " . in_array(55, $food_045,true) ."</br>"; //true = exact match
echo in_array(55, $food_045,true); /* ---- strict mode------ */
// search whole array in nested array
$a_045 = array(array('p', 'h'), array('p', 'r'), 'o'); // mD array
if (in_array(array('p', 'h'), $a_045)){ // need to search array('p', 'h') in $a_045
echo "Find the array .</br>";
}else{
echo "Can't Find.</br>";
}
echo "</br>";
?>