<?php $arr = ["{A}", "{B}", "{C}", "{A}"]; $start = '<span class="c">'; $end = '</span>'; $string = "{A}{B}{C}{A}"; foreach (array_unique($arr) as $item) { $string = str_replace($item, $start . $item . $end, $string); } echo $string;
You have javascript disabled. You will not be able to edit any code.