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); if (preg_match('#\[:'+$lang + '\](.*)\[:#isuU', $find[0], $matches)) { return $matches[1]; } }, $html);
based on fFTrv
Output for 7.1.0 - 7.2.0
Warning: A non-numeric value encountered in /in/LMJWK on line 12 Warning: A non-numeric value encountered in /in/LMJWK on line 12 Warning: A non-numeric value encountered in /in/LMJWK on line 12 Warning: preg_match(): Delimiter must not be alphanumeric or backslash in /in/LMJWK on line 12 <div> <img src='/logo.png'> </div>
Output for 5.3.22 - 7.0.20
Warning: preg_match(): Delimiter must not be alphanumeric or backslash in /in/LMJWK on line 12 <div> <img src='/logo.png'> </div>