php array has value
snippet in php

in array php

user9415

<?php
$people = array("Peter", "Joe", "Glenn", "Cleveland");
if (in_array("Glenn", $people)){
	echo "Match found";
}
else{
	echo "Match not found";
}
?>

php array has value

user9255

$myArr = [38, 18, 10, 7, "15"];

echo in_array(10, $myArr); // TRUE
echo in_array(19, $myArr); // TRUE

// Without strict check
echo in_array("18", $myArr); // TRUE
// With strict check
echo in_array("18", $myArr, true); // FALSE

in_array

user8341


<?php

$people = array("Peter", "Joe", "Glenn", "Cleveland");



if (in_array("Glenn", $people))

  {

  echo "Match found";

  }

else

  {

  echo "Match not found";

  }

?>
 

in_array php

user8210

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

check null in_array php

user3886

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

in_array

user6104


<?
in_array("Irix", $os);
?>