korazy Posted April 15, 2009 Share Posted April 15, 2009 Why does the following is_dir command return false when the directory name is all numeric e.g. /folder/2004/02, is_dir return false on /folder/2004 Development is done a windows xp with apache. production is on a godaddy shared linux hosting server. <?php list_dir('.',true); function list_dir($path,$recurse) { $d = array(); $f = array(); if ($handle = opendir($path)) { print('<h3>'.substr($path,1).'</h3>'); while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { if (is_dir($file.'/')==true) { $d[] = $file; } else { $f[] = $file; } } } closedir($handle); sort($d); sort($f); print('<table>'); // print foreach ($f as $i) { if (substr($i,0,1)!='.') { $fpath = $path.'/'.$i; $d1 = time(); $d2 = filemtime($fpath); $i1 = ($d1 - $d2)/60/60/24; print('<tr>'); print('<td width=300><a href="'.$fpath.'">'.$i.'</a></td>'); print('<td align=right width=160>'); if ($i1<3) { print('<b>'); } print(date("Y-m-d H:i:s", $d2)); if ($i1<3) { print('</b>'); } print('</td>'); print('<td align=right width=160>'.number_format(filesize($fpath)/1000,0,'.',',').' KB</td>'); print('</tr>'); } } print('</table>'); if ($recurse==true) { foreach ($d as $i) { list_dir($path.'/'.$i,$recurse); } } } } ?> Link to comment https://forums.phpfreaks.com/topic/154158-why-does-is_dir-return-false-when-numeric-directory-name/ Share on other sites More sharing options...
WolfRage Posted April 15, 2009 Share Posted April 15, 2009 Try === instead of ==. Link to comment https://forums.phpfreaks.com/topic/154158-why-does-is_dir-return-false-when-numeric-directory-name/#findComment-810367 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.