Function can see variable

is this right?

    foreach ($images as $image) {

	$ext = strtolower(pathinfo($image['name'], PATHINFO_EXTENSION));

if( (in_array($ext, ['jpg', 'jpeg', 'gif', 'png', 'bmp']) && ($image["size"] < 512000)) ){ 
     
    $filename = $image['name'];
    $source = $image['tmp_name'];   
    $target = $path_to_image_directory . $filename;
     
    move_uploaded_file($source, $target);
         
    createThumbnail($filename);     
} else {
	echo "<p class='text-danger'><span class='glyphicon glyphicon-remove'></span>&nbsp;&nbsp;Error: File too big ( < 500Kb) or wrong type (gif, jpg, bmp, or png)</p>";
}
} 

Cause that seems like it should work, cept I tried it and nothing