PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?php
// get template directory (wordpress)
$templateDir = get_bloginfo(template_directory);
// get current directory
getcwd();
// change to directory we want
chdir('wp-content\themes\ldexterldesign\images\logos\accreditors\hoverOff');
// make a variable of the path
$cwd = getcwd();
// get all the filenames
$files = scandir($cwd);
// count total files in directory
$totalFiles = count($files);
// get end directory from the $cwd
$endDirectory = explode('\\', $templateDir);
// spit out the filenames with img tag HTML
echo '<ul id="accreditors">';
for($i = 1; $i <= $totalFiles-1; $i++){
echo '<li>';
echo '<a href="#">';
echo '<img src="';
echo $templateDir;
echo '/images/logos/accreditors/hoverOff/';
echo $files[$i];
echo '"/>';
echo '</a>';
echo '</li>';
}
echo '</ul>';
?>
I'm keen to use the glob() function as @pickle kindly pointed out, but am at a loss as to how and where to implement it (even if it's the correct solution at all!)
If you have a new question, even if its related, please post it in a new thread. If you edit your most recent post to have a relevant subject, I can move it to a new thread for you.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.