Tammy Posted November 8, 2008 Share Posted November 8, 2008 Okays I want it so it'll display just the files in the folder except for the file you view it in so say in the icon folder there's pink-icons.php purple-icons.php index.php images/ All I want to be dislayed in the index.php are pink-icons.php purple-icons.php WHen it's displayed I don't want it wit hthe .php just pink icons So without the hypen or underscore. So far that's the code I've got and it shows all the folders and files in that folder so it shows: pink-icons.php purple-icons.php index.php images/ and when you view it via web page it shows pink-icons.php purple-icons.php index.php images <?php include('/home/.tadd/glitterblast/glitterblast.com/header.php');?> <?php $dirname = '/home/.tadd/glitterblast/glitterblast.com/icons'; // adjust as needed, such as 'C:\web_root\download_folder' for Windows $webdirname = '/icons'; // what the directory appears as from the web browser's point of view $dir = opendir($dirname); $file_list = ''; while(($file = readdir($dir)) != false) { if(($file != '.') && ($file != '..')) { $file_list .= "<a class=\"subnav\" href=\"$webdirname/$file\">$file</a>"; } } closedir($dir); ?> <?=$file_list?> <?php include('/home/.tadd/glitterblast/glitterblast.com/footer.php');?> Quote Link to comment https://forums.phpfreaks.com/topic/131875-easy-fix-add/ Share on other sites More sharing options...
wildteen88 Posted November 8, 2008 Share Posted November 8, 2008 Change while(($file = readdir($dir)) != false) { if(($file != '.') && ($file != '..')) { $file_list .= "<a class=\"subnav\" href=\"$webdirname/$file\">$file</a>"; } } to // list files to ignore $ignore = array( '.', '..', 'index.php'); while(($file = readdir($dir)) != false) { // check that the current file is not within the $ignore list // and that it is not a directory if(!in_array($file, $ignore) && !is_dir($file)) { // add the file to the list $file_list .= "<a class=\"subnav\" href=\"$webdirname/$file\">$file</a>"; } } Quote Link to comment https://forums.phpfreaks.com/topic/131875-easy-fix-add/#findComment-685245 Share on other sites More sharing options...
Tammy Posted November 9, 2008 Author Share Posted November 9, 2008 ^ YAY IT worked but one more problem it displays pink-icons.php I want it to show up as: pink icons so without the hypen and the .php Quote Link to comment https://forums.phpfreaks.com/topic/131875-easy-fix-add/#findComment-685804 Share on other sites More sharing options...
Andy-H Posted November 9, 2008 Share Posted November 9, 2008 Try // list files to ignore $ignore = array( '.', '..', 'index.php'); while(($file = readdir($dir)) != false) { // check that the current file is not within the $ignore list // and that it is not a directory if(!in_array($file, $ignore) && !is_dir($file)) { // add the file to the list $str = substr($file, 0, -4); /// strip the .php $str = explode("-", $str); // explode to remove hyphen(s) $str = implode(" ", $str); // implode the hyphen(s) back into spaces $file_list .= "<a class=\"subnav\" href=\"$webdirname/$file\">$str</a>"; } } // and cross your fingers lol Quote Link to comment https://forums.phpfreaks.com/topic/131875-easy-fix-add/#findComment-685839 Share on other sites More sharing options...
Tammy Posted November 9, 2008 Author Share Posted November 9, 2008 ^ yess it works thank you soo much!!! Quote Link to comment https://forums.phpfreaks.com/topic/131875-easy-fix-add/#findComment-685876 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.