PHP bash command line stdin

Read stdin using php on the command line.

listdir ()
{
    ls | sort | php -r '
        while ($line = fgets(STDIN)) {
            $filename = rtrim($line);
            $modified = date(DATE_W3C, filemtime($filename));
            echo "$modified $filename\n";
        }
    '
}
Did this help you? Please let me know with a comment. Thank you
Posted .

Comments (RSS)

Leave a comment