- in_array: documentation ( source)
- strtolower: documentation ( source)
<?php
$ok_exts = array("jpg", "jpeg", "png", "gif", "bmp");
$file_check = strtolower('jpg');
if (in_array($file_check, $ok_exts)) {
echo 'true';
}
else {
echo 'false';
}
echo PHP_EOL;
$file_check = strtolower('JPG');
if (in_array($file_check, $ok_exts)) {
echo 'true';
}
else {
echo 'false';
}
echo PHP_EOL;
$file_check = strtolower('PDF');
if (in_array($file_check, $ok_exts)) {
echo 'true';
}
else {
echo 'false';
}
echo PHP_EOL;