Created
May 10, 2019 15:27
-
-
Save ninsuo/d41ba41c9aa24ce06298225df4f83858 to your computer and use it in GitHub Desktop.
Takes each line in stdin, and wrap it with a template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!isset($argv[1])) { | |
die(sprintf('You forgot to give a template: %s "<prefix> %%s <suffix>"%s', $argv[0], "\n")); | |
} | |
$template = $argv[1]; | |
$raw = file_get_contents('php://stdin'); | |
$lines = explode(PHP_EOL, $raw); | |
foreach ($lines as $line) { | |
echo str_replace('%s', $line, $template), PHP_EOL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment