How can we check if an element exists in an array php? code example
Example 1: php array index exists
$fruits = ['apple', 'pear', 'banana'];
if (array_key_exists("banana", $fruits)) {
}
$exists = array_key_exists("peach", $fruits);
return array_key_exists("pineapple", $fruits);
Example 2: 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))