|
Posted by Ivan Omelchenko 608308824 on 10/01/48 11:19
duncan.lovett@litho.co.uk пишет:
> 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);
>
>
> echo $final;
> ?>
>
>
> 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?
>
>
> Thanks,
> DL
>
hows about preg_replace instead of str_replace ?
Navigation:
[Reply to this message]
|