3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php echo mb_substr('123abcdef', 3); echo "\n"; function endingCodeTag($content, $n) { $contentRest = mb_substr($content, $n); preg_match('/^\<code\s+lang(?:[\s]*>|\W[^\>]*\>)/u', $contentRest, $resultArr); if(!empty($resultArr[0])) return $resultArr[0]; else return ''; } var_dump (endingCodeTag('<p> f g f rt e</p> <code lang>df g df = \(fsgfsd', 20)); var_dump (endingCodeTag('<p> f g f rt e</p> <code lang>df g df = \(fsgfsd', 18)); var_dump (endingCodeTag('<p> f g f rt e</p> <code lang>df g df = \(fsgfsd', 19)); var_dump (endingCodeTag('<p> f g f rt e</p> <code lang>df g df = \(fsgfsd', 21)); var_dump (endingCodeTag('<p> f g f rt e</p> <code lang>df g df = \(fsgfsd', 22)); var_dump (endingCodeTag('<p> f g f rt e</p> <code lang>df g df = \(fsgfsd', 23)); var_dump (endingCodeTag('<p> f g f rt e</p> <code lang>df g df = \(fsgfsd', 24));
based on 9ik35
Output for 5.6.0 - 7.3.0beta1
abcdef string(11) "<code lang>" string(0) "" string(0) "" string(0) "" string(0) "" string(0) "" string(0) ""