<?php
str|false readdir ( res $dir_handle = ? )
where,
$dir_handle = The directory handle as resource
previously opened with opendir
?>
<?php
$d01 = __DIR__ . '/temp/';
if($hdl01 = opendir($d01))
{
echo '[ ' . $hdl01 . ' ] Directory is open!<br><br>';
$rd01 = readdir($hdl01);
while(false !== ($rd01 = readdir($hdl01) ))
{
if($rd01 != '.' && $rd01 != '..')
{
echo $rd01 . '<br>';
}
}
closedir($hdl01);
echo '<br>';
}
else
{
echo 'Directory CANNOT be opened.<br><br>';
}
?>
<?php
$d02 = 'file://' . __DIR__ . '/temp/';
// STREAM WRAPPER
if($hdl02 = opendir($d02))
{
echo '[ ' . $hdl02 . ' ] Directory is open!<br><br>';
$rd02 = readdir($hdl02);
while(false !== ($rd02 = readdir($hdl02) ))
{
if($rd02 != '.' && $rd02 != '..')
{
echo $rd02 . '<br>';
}
}
closedir($hdl02);
echo '<br>';
}
else
{
echo 'Directory CANNOT be opened.<br><br>';
}
?>
<?php
$d03 = 'temp/t1';
if($hdl03 = opendir($d03))
{
echo '[ ' . $hdl03 . ' ] Directory is open!<br><br>';
$rd03 = readdir($hdl03);
while(false !== ($rd03 = readdir($hdl03) ))
{
if($rd03 != '.' && $rd03 != '..')
{
echo $rd03 . '<br>';
}
}
closedir($hdl03);
echo '<br>';
}
else
{
echo 'Directory CANNOT be opened.<br><br>';
}
?>