@ 2016-01-23T06:18:00Z <?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, $matches)) {
return $matches[1];
}
}, $html);
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 8.2.0 - 8.2.18 , 8.3.0 - 8.3.6 Fatal error: Uncaught TypeError: Unsupported operand types: string + string in /in/iO0Jv:12
Stack trace:
#0 [internal function]: {closure}(Array)
#1 /in/iO0Jv(9): preg_replace_callback('#\\[:.*\\[:\\]#isu...', Object(Closure), '<div>\n<img src=...')
#2 {main}
thrown in /in/iO0Jv on line 12
Process exited with code 255 . Output for 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 Fatal error: Uncaught TypeError: Unsupported operand types: string + string in /in/iO0Jv:12
Stack trace:
#0 [internal function]: {closure}(Array)
#1 /in/iO0Jv(15): preg_replace_callback('#\\[:.*\\[:\\]#isu...', Object(Closure), '<div>\n<img src=...')
#2 {main}
thrown in /in/iO0Jv on line 12
Process exited with code 255 . Output for 7.1.0 - 7.1.33 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 Warning: A non-numeric value encountered in /in/iO0Jv on line 12
Warning: A non-numeric value encountered in /in/iO0Jv on line 12
Warning: A non-numeric value encountered in /in/iO0Jv on line 12
Warning: preg_match() expects parameter 2 to be string, array given in /in/iO0Jv on line 12
<div>
<img src='/logo.png'>
</div> Output for 5.5.0 - 5.5.38 , 5.6.0 - 5.6.40 , 7.0.0 - 7.0.33 Warning: preg_match() expects parameter 2 to be string, array given in /in/iO0Jv on line 12
<div>
<img src='/logo.png'>
</div> preferences:dark mode live preview
239.36 ms | 402 KiB | 330 Q