Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If your <code>&lt;?php ?&gt;</code> tags are always gonna me at the top of your input file, you could just explode the input and write to your output everything around your tags:</p> <p>Input:</p> <pre><code>&lt;?php echo "This is the PHP I want removed!"; ?&gt; &lt;html&gt; &lt;p&gt;This is what I want written to a file!&lt;/p&gt; &lt;/html&gt; </code></pre> <p>Code: <pre><code>$inputTxt = file_get_contents($path . $file , NULL, NULL); $begin = explode("&lt;?php", $inputTxt); $end = explode('?&gt;', $inputTxt); fwrite($output, $begin[0] . $end[1] . "\n\n"); ?&gt; </code></pre> <p>Output:</p> <p><strong>Before</strong></p> <pre><code>&lt;?php echo "This is the PHP I want removed!"; ?&gt; &lt;html&gt; &lt;p&gt;This is what I want written to a file!&lt;/p&gt; &lt;/html&gt; </code></pre> <p><strong>After</strong></p> <pre><code>&lt;html&gt; &lt;p&gt;This is what I want written to a file!&lt;/p&gt; &lt;/html&gt; </code></pre> <p>But, if you plan on having more than one set of <code>&lt;?php ?&gt;</code> tags, then you would need to use preg_match:</p> <p>Input:</p> <pre><code>&lt;?php echo "This is the PHP I want removed!"; ?&gt; &lt;html&gt; &lt;p&gt;This is &lt;?php echo $something; ?&gt; I want written to a file!&lt;/p&gt; &lt;/html&gt; </code></pre> <p>Code:</p> <pre><code>&lt;?php $file="input.txt"; $path='C:\\input\\'; $output = fopen($path . "output.txt",'w'); $inputTxt = file_get_contents($path . $file , NULL, NULL); $pattern = '/&lt;\?php.+\?&gt;/isU'; $replace = ''; $newInput = preg_replace($pattern, $replace, $inputTxt); fwrite($output, $newInput); ?&gt; </code></pre> <p>Output:</p> <p><strong>Before</strong></p> <pre><code>&lt;?php echo "This is the PHP I want removed!"; ?&gt; &lt;html&gt; &lt;p&gt;This is &lt;?php echo $something; ?&gt; I want written to a file!&lt;/p&gt; &lt;/html&gt; </code></pre> <p><strong>After</strong></p> <pre><code>&lt;html&gt; &lt;p&gt;This is I want written to a file!&lt;/p&gt; &lt;/html&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload