<?php $str = '§f§lWORDHERE'; $replacements = [ '§f' => '<span style="color: white;">$0</span>', '§l' => '<b>$0</b>', ]; if (preg_match('/^(?<flags>(?:§[a-z])+)(?<string>.*)/iu', $str, $matches)) { $str_res = $matches['string']; foreach (mb_str_split($matches['flags'], 2) as $flag) { $str_res = preg_replace('/.+/', $replacements[$flag], $str_res); } echo $str_res; }
You have javascript disabled. You will not be able to edit any code.