note 117910 added to features.commandline.io-streams
| From: | anthony at teamug dot net | Date: | Mon, 31 Aug 2015 07:55:57 +0000 |
| Subject: | note 117910 added to features.commandline.io-streams | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-203529@lists.php.net to get a copy of this message | ||
My editor (Geany) allows me to run blocks of text through a specified script, replacing it with the
output.
I use this code to perform multiple search and replaces in PHP I'm recoding:
<?php
$arr = array(
array('include', 'require_once'),
array('DIR_INC', 'DIR_TEMPLATES'),
);
while(!feof(STDIN)){
$line = fgets(STDIN);
foreach($arr AS $sr){
$line = str_replace($sr[0], $sr[1], $line);
}
fwrite(STDOUT, $line);
}
?>
Note: Ensure this script has no leading/trailing new lines, as these will be introduced into the
output.
----
Server IP: 72.52.91.14
Probable Submitter: 86.140.42.149
----
Manual Page -- http://php.net/manual/en/features.commandline.io-streams.php
Edit -- https://master.php.net/note/edit/117910
Del: integrated -- https://master.php.net/note/delete/117910/integrated
Del: useless -- https://master.php.net/note/delete/117910/useless
Del: bad code -- https://master.php.net/note/delete/117910/bad+code
Del: spam -- https://master.php.net/note/delete/117910/spam
Del: non-english -- https://master.php.net/note/delete/117910/non-english
Del: in docs -- https://master.php.net/note/delete/117910/in+docs
Del: other reasons-- https://master.php.net/note/delete/117910
Reject -- https://master.php.net/note/reject/117910
Search -- https://master.php.net/manage/user-notes.php