3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = 'ê[B]éîøoo[/B]åaí'; $isMatch = preg_match( '/\[(\w++)([=]?)([^\]]*?)\]([^\[]*?)\[\/\1\]|\[(HR|\*)\]/', $string, $matches ); if($isMatch) { echo str_replace( "[{$matches[1]}]{$matches[4]}[/{$matches[1]}]", "<b>{$matches[4]}</b>", $string ); }

preferences:
71.36 ms | 402 KiB | 5 Q