<?php $allowed_ext = array ( 'bmp', 'jpg', 'jpeg', 'gif', 'pdf' ); $arr = array( 1 => 'file-to-path/thumbs/allowedfile.pdf', 2 => 'file-to-path/thumbs/notallowedfile.psd', 3 => 'file-to-path/project/test/notallowedfile.txt' ); $errors = []; foreach ($arr as $key => $value) { if (!in_array(pathinfo($value, PATHINFO_EXTENSION), $allowed_ext)) { $errors[] = basename($value).' is not allowed.'; unset($arr[$key]); } } print_r($errors); print_r($arr);
You have javascript disabled. You will not be able to edit any code.