• Heya,
    I’m trying to list only the folders in this directory but as soon as I add the is_dir($file) it lists nothing. If I remove it it will list files and directories. Can someone help? Thanks!

    if ($handle = opendir('../wp-content/plugins/tpc-slideshow/themes')) {
    
    	while (false !== ($file = readdir($handle))) {
    		if( $file != '.' && $file != '..' && is_dir($file) ) {
    			echo "<p>$file</p>";
    		}
    	}
    
    	closedir($handle);
    }
Viewing 1 replies (of 1 total)
  • Moderator Dion Hulse

    (@dd32)

    Meta Developer

    is_dir() needs the full path, so something such as:

    is_dir('../wp-content/plugins/tpc-slideshow/themes/' . $file)

Viewing 1 replies (of 1 total)
  • The topic ‘Trying to list all folders in a directory with PHP, need help…’ is closed to new replies.