PHP - Check if a file exists in a folder
<p>I wanna check if there any image on a folder from my server. I have this little function in PHP but is not working and I don't know why:</p>

<pre><code>$path = 'folder/'.$id;
function check($path) {
    if ($handle = opendir($path)) {
        $array = array();
        while (false !== ($file = readdir($handle))) {
            if ($file != "." &amp;&amp; $file != ".." &amp;&amp; count &gt; 2) {
                echo "folder not empty";
            } else {
                echo "folder empty";
            }
        }
    }
    closedir($handle);
}
</code></pre>

<p>Any help will be appreciated, thanks in advance.</p>
