KBS Syllabi
[
Search
]
[
Home
]
[
People
] [
Education
] [
Research
] [
Publications
] [
Documentation
] [
Local
]
[
Conference papers
] [
Journal articles
] [
Book contributions
] [
PhD Theses
] [
MSc Theses
] [
BSc Theses
]
[
Reports
] [
Syllabi
] [
Practical assignments
]
2006
function preg_ls ($path=".", $rec=false, $pat="/.*/") { $pat=preg_replace ("|(/.*/[^S]*)|s", "\\1S", $pat); while (substr ($path,-1,1) =="/") $path=substr ($path,0,-1); if (!is_dir ($path) ) $path=dirname ($path); if ($rec!==true) $rec=false; $d=dir ($path); $ret=Array (); while (false!== ($e=$d->read () ) ) { if ( ($e==".") || ($e=="..") ) continue; if ($rec && is_dir ($path."/".$e) ) { $ret=array_merge ($ret,preg_ls($path."/".$e,$rec,$pat)); continue; } if (!preg_match ($pat,$e) ) continue; $ret[]=$path."/".$e; } return (empty ($ret) && preg_match ($pat,basename($path))) ? Array ($path."/") : $ret; } $a=preg_ls("../../docs/syllabi", true); foreach ($a as $file) echo "
".basename($file)."
".round((filesize($file)/1024))." KB
"; ?>