in_array php example

Example 1: in_array php

<?php
$os = array("Apple", "Banana", "Lemon");
if (in_array("Apple", $os)) {
    echo "Yeah. Exist Apple";
}
if (!in_array("Buleberry", $os)) {
    echo "Oh, Don't Exist Blueberry!!!";
}
?>

Example 2: in_array

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

Example 3: php value in array

in_array ( mixed $needle , array $haystack , bool $strict = false ) : bool

Example 4: check null in_array php

if (!empty($data_days) && in_array(1, $data_days, true)){ // use numeric value 1, not string

Example 5: in_array

in_array ( mixed $needle , array $haystack [, bool $strict = FALSE ] ) : bool