3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = <<<'AHA' abc [code lang='javascript'] var a = 2.5; [/code] bcd [code lang='php'] $this->foo(); [/code] cde [code lang='html'] <p clas = 'bar'><span>hello world</span></p> [/code] def AHA; $r='/((^|\[\/code\]).*?(\[code[^\]]*?\]|$))/s'; preg_match_all($r, $str, $a); print_r($a[0]);

preferences:
60.35 ms | 402 KiB | 5 Q