I am trying to make a text replacer but since there are letters repeated i keep getting things i dont want. Does anyone know how i can do this?
Input
function image($img) {
$img = ereg_replace("a","<img src=r/a.png>", $img);
$img = ereg_replace("b","<img src=r/b.png>", $img);
$img = ereg_replace("c","<img src=r/c.png>", $img);
return $img;
}
$img = "abc";
echo image($img);
Output
<img sr<img src=r/c.png>=r/a.png><img sr<img src=r/c.png>=r/b.png><img src=r/c.png>
Output I Want
<img src=r/a.png><img src=r/b.png><img src=r/c.png>