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";
        }
    '

}
View this page on GitHub.
Posted .

Comments

Leave a Reply