note 117910 deleted from features.commandline.io-streams by tularis

From: Date: Mon, 31 Aug 2015 20:35:54 +0000
Subject: note 117910 deleted from features.commandline.io-streams by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-203538@lists.php.net to get a copy of this message
Note Submitter: anthony at teamug dot net ---- 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.

« previous php.notes (#203538) next »