1$myArr = [38, 18, 10, 7, "15"];
2
3echo in_array(10, $myArr); // TRUE
4echo in_array(19, $myArr); // TRUE
5
6// Without strict check
7echo in_array("18", $myArr); // TRUE
8// With strict check
9echo in_array("18", $myArr, true); // FALSE
1<?php
2$os = array("Apple", "Banana", "Lemon");
3if (in_array("Apple", $os)) {
4 echo "Yeah. Exist Apple";
5}
6if (!in_array("Buleberry", $os)) {
7 echo "Oh, Don't Exist Blueberry!!!";
8}
9?>
1$colors = array("red", "blue", "green");
2
3if (in_array("red", $colors)) {
4 echo "found red in array";
5}
1<?php
2$os = array("Mac", "NT", "Irix", "Linux");
3if (in_array("Irix", $os)) {
4 echo "Existe Irix";
5}
6if (in_array("mac", $os)) {
7 echo "Existe mac";
8}
9?>
1in_array ( mixed $needle , array $haystack [, bool $strict = FALSE ] ) : bool
2
3// Without strict check
4echo in_array("18", $myArr); // TRUE
5// With strict check
6echo in_array("18", $myArr, true); // FALSE