- var_export: documentation ( source)
- preg_replace: documentation ( source)
<?php
$texts[] = <<<TEXT
EXCLUDE this entire line
include this line
even this to EXCLUDE
and EXCLUDE this
and this as single match
and EXCLUDE this line
TEXT;
$texts[] = <<<TEXT
EXCLUDE this entire line
and EXCLUDE this
and this as single match
TEXT;
$texts[] = <<<TEXT
EXCLUDE this entire line
even this to EXCLUDE
and EXCLUDE this
and EXCLUDE this line
TEXT;
$texts[] = <<<TEXT
include this line
even this to EXCLUDE
TEXT;
var_export(
preg_replace('/(\R)?.*\bEXCLUDE\b.*(?(1)|\R?)/', '', $texts)
);