3v4l.org

run code in 300+ PHP versions simultaneously
<?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) );
Output for 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
array ( 0 => 'include this line and this as single match', 1 => 'and this as single match', 2 => '', 3 => 'include this line', )

preferences:
73.76 ms | 406 KiB | 5 Q