note 61417 deleted from function.strpos by danbrown
| From: | danbrown@php.net | Date: | Sun, 17 May 2009 16:36:21 +0000 |
| Subject: | note 61417 deleted from function.strpos by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-154862@lists.php.net to get a copy of this message | ||
Note Submitter: luko1 at centrum dot cz
----
<?php //prepocet velikosti souboru
function format($soubor) {
$velikost = filesize($soubor);
if($velikost < 1048576):
return number_format(($velikost / 1024), 2, ',', ' ')." kB";
else:
return number_format(($velikost / 1024 / 1024), 2, ',', ' ')."
MB";
endif;
}
?>
<?php
function read_dir($dir)
{
$path = opendir($dir);
while (false !== ($file = readdir($path))):
if ($file!="." && $file!=".."):
if (is_file($dir."/".$file)):
$items[] = $file;
else:
$items[] = $dir."/".$file;
endif;
endif;
endwhile;
closedir($path);
if ($items):
natcasesort($items);
foreach ($items as $item){
if (is_dir($item)):
$dir1 = $item;
$item1 = substr($item, strrpos($item, '/') + 1).'/';
echo "<b>$item1</b><table border=1 style='margin-left: 60px;
position: static; border: blue'><tr><td>";
read_dir($dir1);
echo "</table>";
else:
$cesta_file = "\"".$dir."/".$item."\"";
$cesta_size = $dir."/".$item;
echo "<span class=pop> <a href=$cesta_file
title=$item>$item</a> <span> - ".format($cesta_size)."</span>
</span><br>";
endif;
} //endforeach
endif;
}
?>
...
<table><tr><td>
<?php
$dir = ".";
read_dir($dir);
?>
</table>