Skip to content

Instantly share code, notes, and snippets.

@sayhicoelho
Created June 22, 2017 00:47
Show Gist options
  • Save sayhicoelho/f8d2a510b523d284406f87174197aff2 to your computer and use it in GitHub Desktop.
Save sayhicoelho/f8d2a510b523d284406f87174197aff2 to your computer and use it in GitHub Desktop.
Replace string between
<?php
function replace_between($str, $needle_start, $needle_end, $replacement = '')
{
return preg_replace('/' . $needle_start . '.+?' . $needle_end . '/sm', $replacement, $str);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment