I'm trying to get rid of php code in a file using regex. Some of the php is not well-formatted, so that there may be extra spaces and/or line breaks. As an example:
<?php require_once('some_sort_of_file.php');
?>
I've come up with the following regex which seems to work:
$initial_text = preg_replace('/\s+/', ' ', $initial_text );
$initial_text = preg_replace('/' . preg_quote('<?php') . '.*?' . preg_quote('?>') . '/', '', $initial_text);
but was wondering if there might be a way to just use 1 regex statement, in order to speed things up.
Thanks!