in array of array php code example

Example 1: php in array

$colors = array("red", "blue", "green"); 
 
if (in_array("red", $colors)) { 
	echo "found red in array"; 
}

Example 2: in_array php

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

Example 3: php check if item in array

$allowedFileType = ['application/vnd.ms-excel','text/xls','text/xlsx','application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'];
  
if(in_array($_FILES["file"]["type"],$allowedFileType))

Tags:

Php Example