Include all PHP files from a directory except one 'index.php'
<p>I have the following PHP code that scans a directory and sub folders and lists all the PHP files in iframes.
I want to include all the PHP files from the directory except one, any instance of 'index.php'.</p>

<p>I've tried adding:</p>

<pre><code> if ($file != "." &amp;&amp; $file != ".." &amp;&amp; $file != 'index.php')
</code></pre>

<p>But it doesn't work.
Here's the full code:</p>

<pre><code>&lt;?php
$iterator = new RecursiveDirectoryIterator('work/');

foreach( new RecursiveIteratorIterator($iterator) as $filename =&gt; $cur) {
$file_info = pathinfo($filename);

if($file_info['extension'] === 'php') {
    if ($file != "." &amp;&amp; $file != ".." &amp;&amp; $file != 'index.php')

    echo 
  "&lt;iframe width=420 height=150 frameborder=1 src='$filename'&gt;&lt;/iframe&gt;";
}
}

?&gt;
</code></pre>

<p>Thanks!</p>
