3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $html = "<div> <img src='/logo.png'>[:ru]Привет мир[:en]Hello World[:] </div>"; $lang = 'ru'; echo preg_replace_callback('|\[:.*\[:\]|isuU', function ($find) use ($lang) { //print_r($matches); echo '|\[\:' + $lang + '\](.*)\[\:|isuU'; if (preg_match('|\[\:' + $lang + '\](.*)\[\:|isuU', $find[0], $matches)) { return $matches[1]; } }, $html);
based on keR2I
Output for 7.1.0 - 7.2.0
Warning: A non-numeric value encountered in /in/NgKMD on line 12 Warning: A non-numeric value encountered in /in/NgKMD on line 12 Warning: A non-numeric value encountered in /in/NgKMD on line 12 0 Warning: A non-numeric value encountered in /in/NgKMD on line 13 Warning: A non-numeric value encountered in /in/NgKMD on line 13 Warning: A non-numeric value encountered in /in/NgKMD on line 13 Warning: preg_match(): Delimiter must not be alphanumeric or backslash in /in/NgKMD on line 13 <div> <img src='/logo.png'> </div>
Output for 5.3.22 - 7.0.20
0 Warning: preg_match(): Delimiter must not be alphanumeric or backslash in /in/NgKMD on line 13 <div> <img src='/logo.png'> </div>