PHPFusion\OutputHandler::replaceInOutput PHP Method

replaceInOutput() public static method

Replace something in the output using regexp
public static replaceInOutput ( string $target, string $replace, string $modifiers = "" )
$target string Regexp pattern without delimiters
$replace string The new content
$modifiers string Regexp modifiers
    public static function replaceInOutput($target, $replace, $modifiers = "")
    {
        self::$outputHandlers[] = function ($output) use($target, $replace, $modifiers) {
            return preg_replace('^' . preg_quote($target, "^") . '^' . $modifiers, $replace, $output);
        };
    }

Usage Example

/**
 * Replace something in the output using regexp
 *
 * @param string $target Regexp pattern without delimiters
 * @param string $replace The new content
 * @param string $modifiers Regexp modifiers
 */
function replace_in_output($target, $replace, $modifiers = "")
{
    OutputHandler::replaceInOutput($target, $replace, $modifiers);
}