I am using the below script to validate if uploaded files are image for a multiple upload form. Everything works but I want to further validate that the uploaded files are png or jpg only. How do I accomplish this? I am new to php so any help will be appreciated. thanks.

PHP Code:
        $images = array();
        
$pic $_FILES['file']['tmp_name'];
        foreach(
$pic as $image){
          if(!empty(
$image)) {
              if(!
getimagesize($image)){
        
$errors['image_error'] = "PNG and JPG Files ONLY.";
    }
    }}