note 100214 added to function.fread
| From: | Anonymous at osu1 dot php dot net | Date: | Fri, 01 Oct 2010 13:25:14 +0000 |
| Subject: | note 100214 added to function.fread | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-172875@lists.php.net to get a copy of this message | ||
Stream editor on php
#/bin/php
<?php
if (ftell(STDIN) !== 0) {
fwrite(STDERR, "Pipe error\n");
exit(1);
}
$input = '';
while (true) {
$input = trim(fread(STDIN,10240));
if (feof(STDIN)) break;
if ($input === false || strlen($input) === 0) {
continue;
}
// replase '<br />' to 'newline'
$input = preg_replace('/<br\s*\/>/', "\n\t", $input);
fwrite(STDOUT, $input . "\n");
}
?>
Example:
cat some.html | this_script.php | grep something
Keyword list: pipe, tail, grep, sed
----
Server IP: 69.147.83.197
Probable Submitter: 82.179.113.192
----
Manual Page -- http://www.php.net/manual/en/function.fread.php
Edit -- https://master.php.net/note/edit/100214
Del: integrated -- https://master.php.net/note/delete/100214/integrated
Del: useless -- https://master.php.net/note/delete/100214/useless
Del: bad code -- https://master.php.net/note/delete/100214/bad+code
Del: spam -- https://master.php.net/note/delete/100214/spam
Del: non-english -- https://master.php.net/note/delete/100214/non-english
Del: in docs -- https://master.php.net/note/delete/100214/in+docs
Del: other reasons-- https://master.php.net/note/delete/100214
Reject -- https://master.php.net/note/reject/100214
Search -- https://master.php.net/manage/user-notes.php