<?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);
return $resultArr[0];
}
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));
abcdef
string(11) "<code lang>"
Warning: Undefined array key 0 in /in/9ik35 on line 10
NULL
Warning: Undefined array key 0 in /in/9ik35 on line 10
NULL
Warning: Undefined array key 0 in /in/9ik35 on line 10
NULL
Warning: Undefined array key 0 in /in/9ik35 on line 10
NULL
Warning: Undefined array key 0 in /in/9ik35 on line 10
NULL
Warning: Undefined array key 0 in /in/9ik35 on line 10
NULL
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
abcdef
string(11) "<code lang>"
Warning: Undefined array key 0 in /in/9ik35 on line 10
NULL
Warning: Undefined array key 0 in /in/9ik35 on line 10
NULL
Warning: Undefined array key 0 in /in/9ik35 on line 10
NULL
Warning: Undefined array key 0 in /in/9ik35 on line 10
NULL
Warning: Undefined array key 0 in /in/9ik35 on line 10
NULL
Warning: Undefined array key 0 in /in/9ik35 on line 10
NULL
abcdef
string(11) "<code lang>"
Notice: Undefined offset: 0 in /in/9ik35 on line 10
NULL
Notice: Undefined offset: 0 in /in/9ik35 on line 10
NULL
Notice: Undefined offset: 0 in /in/9ik35 on line 10
NULL
Notice: Undefined offset: 0 in /in/9ik35 on line 10
NULL
Notice: Undefined offset: 0 in /in/9ik35 on line 10
NULL
Notice: Undefined offset: 0 in /in/9ik35 on line 10
NULL