View Single Post
Old 02-23-2009, 09:38 PM   #4 (permalink)
Wildhoney
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

You could still use glob in your current set-up. See the $aExisting variable in the following code, modified from my earlier version.

Sorry to be so persistent, but I still believe the glob function is the best approach. Please correct me if you think I am wrong, and I will take a look at your own code to modify that accordingly !

php Code:
/* Directory with or without trailing slash as rtrim will remove it anyway. */
$szDir = './app/controllers/';

/* Glob acquires all the files for us with the extension specified (WMV). */
$aFiles = glob(rtrim($szDir, '/') . '/*.wmv');

/* Glob already outputs in alphabetical order, so reverse to show it's working. */
$aFiles = array_reverse($aFiles);

/* Get the existing files and don't display those in the subsequent loop. */
$aExisting = array('TestController', 'ErrorController');

foreach ($aFiles as $szFile)
{
    $szFilename = pathinfo($szFile, PATHINFO_FILENAME);
   
    /* If the file exists in the $aExisting array, skip displaying it. */
    if (in_array($szFilename, $aExisting))
    {
        continue;
    }
   
    /* Echo the radio buttons using the relevant data. */
    printf
    (
        '<input type="radio" name="trailer" value="%s" /><font color="black">%s</font><br />',
        $szFilename, basename($szFile)
    );
}
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote