foreach ($theMaps as $map){ if(file_exists('images/maps/'.$map.'.gif')){ echo ''; } else echo=''; }