not sure if this helps but ive used this sometime back
$formats_allowed = Array(
array("image/pjpeg",".jpg"),
array("image/jpeg",".jpg"),
array("image/gif",".gif"),
array("application/octet-stream",".exe")
);
for($i=0;$i<sizeof($formats_allowed );$i++){
if($formats_allowed [$i][0] == $img1_type){
print("Extension is ".$formats_allowed [$i][1]);
print("This format not allowed");
break;
}
}