Skip to content

Instantly share code, notes, and snippets.

@michaeltwofish
Created March 4, 2012 07:15
Show Gist options
  • Save michaeltwofish/1971109 to your computer and use it in GitHub Desktop.
Save michaeltwofish/1971109 to your computer and use it in GitHub Desktop.
<?php
$input = 'some stuff <?= $this->foo ?> blah';
echo $input."\n";
echo preg_replace('/\<\?=\s*\$this->(.+?)\s*;?\s*\?>/msx', '<?php echo $this->$1; ?>', $input)."\n";
// Should output:
some stuff <?= $this->foo ?> blah
some stuff <?php echo $this->foo; ?> blah
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment