Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Sort of Dynamic Image generation - Problem
June 23, 2005, 11:09 am
rate this thread
I am working on a graphical heading generator for a clients website as
their server does not have the GD library or similar plugins for
dynamic image generation.
I have achieved the result partly, from a snipet I found in the user
contributions to the "str_replace" function in the manual on php.net.
However there is a small problem - it only works in uppercase. Please
first see my code below and then a brief description of the problem:
// create a string ..
$txt = "My String Here";
$txt = strtoupper($txt);
// characters to search for
$txts = array ( "A", "B", "C", "D", "E", "F", and so forth );
// images array to replace them with.
$images = array ( "<img src=\"a.gif\" />", "<img src=\"b.gif\" />" ,
"<img src=\"c.gif\" />" , etc );
// continue with the <img src>'s with the number pattern above.
// Now, using str_replace to complete all the replacing.
$final = str_replace ($txts, $images, $txt);
This works fine for my purpose, but, you will notice, I have to convert
my string to upper case characters for it to work.
If the string is in lower case, the str_replace function will replace
all the characters in the $images array as well.
Does anyone know a work around for this, so that i can use lower case
AND upper case characters?