|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-10-09 05:47 UTC] scottayy at gmail dot com
[2006-10-09 09:20 UTC] judas dot iscariote at gmail dot com
[2006-10-09 09:46 UTC] tony2001@php.net
[2006-10-09 09:47 UTC] tony2001@php.net
[2006-10-09 22:49 UTC] scottayy at gmail dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 13:00:02 2025 UTC |
Description: ------------ PHP fails to recognize directories when looping through a directory. filetype() says lstat() fails, and is_dir() returns false. I have the following directory structure. / /themes/ /themes/crap/ /themes/default/ Using this simple script to loop through the themes directory and get directory names: Reproduce code: --------------- <?php //gather available themes function get_available_themes() { if($handle = @opendir('themes')) { $themes = array(); while(false !== ($file = readdir($handle))) { if(is_dir($file) && ($file != '.' && $file != '..')) { $themes[] = $file; } } if(empty($themes)) { return false; } } else { return false; } return $themes; } if($themes = get_available_themes()) { echo '<pre>'; print_r(get_available_themes()); echo '</pre>'; } else { echo 'No themes could be found.'; } ?> Expected result: ---------------- Array ( [0] => crap, [1] => default ) Actual result: -------------- The function returns false because the array actually contains: Array ( ) If I echo out $file during the while() loop, I see . .. crap default