Browsing local directories and files with php
<p>Instead of the traditional navigation, I am trying to emulate the terminal navigation, or how you navigate with vim.
Example:</p>

<pre><code>..
index
otherfile
</code></pre>

<p>This is my code:</p>

<pre><code>$dir = realpath(dirname(__FILE__));
if(is_dir($dir)){
    if($open = opendir($dir)){
        while(($file = readdir($open)) !==false){
        if(is_dir($file)){
             if($file == '.'){ }
             else{
                echo "&lt;a href=".$file."&gt;".$file."&lt;/a&gt;&lt;br/&gt;";
            }
        } 
        else{       
        $name = explode('.php',$file);
        echo "&lt;a href=".$file."&gt;".$name[0]."&lt;/a&gt;&lt;br/&gt;";
        }
        }

    }
}
else{
    echo $dir." Was not found";
    }
 }
</code></pre>

<ol>
<li><p>How can I remove the file or folder I am in from the list? For example, if I am on the page index.php, it is still appearing on the list.</p></li>
<li><p>I want to sort files by given them a number example '1file.php' '2anotherfile.php'..
How could I sort them by the number, then remove the number and '.php', and finally print it out?</p></li>
</ol>

<p>If you feel like refactoring something please do so...</p>

<p><img src="http://i.stack.imgur.com/89ToP.png" alt="enter image description here"></p>
