I'd suggest reading the [man]manual[/man], particular things like [man]fopen/man and [man]fread/man. IIRC, there's a fine tutorial on doing just that.
I'll make mention of the fact that a quick and dirty hack, quite possibly unsafe in a web context, might be:
<?php
$list=`ls -1`;
$listed=explode("\n",$list);
foreach ($listed as $l) {
echo $l."\n";
}