I want to replace all the all the letters in a string with images of the same name (e.g A = A.jpg , a = a.jpg , B = B.jpg).
Only way i can think of it to have separate reg_replace's but this makes the page to slow.
please save me 🙂
I forgot to mention i dont want to create the images. I just want to modify the text string so "blah" = "<img src=b.jpg><img src=l.jpg><img src=q.jpg><img src=h.jpg>";
<?php
$string = "foo";
echo eregi_replace ("([a-z])", "<img src='\1.jpg'>", $string);
// Outputs : <img src='f.jpg'><img src='o.jpg'><img src='o.jpg'>
?>
Essentially, \1 will output the letter, you can put stuff around it.