You'll have to split the output into seperate vars and print them in a formatted way:
execute command an capture output
$dir=ls -al;
split output into lines
$aLines=preg_split("/\n/",$dir);
Loop through each line
for ($t=0;$t<count($aLines);$t++)
{
split the line into words (split around 1+ whitespaces)
$aLineParts=preg_split("/\s+/",$aLines[$t]);
# print word 8, the filename on unix machines
echo $aLineParts[8]."\n";
};