You are here: Re: Sort of Dynamic Image generation - Problem « PHP Programming Language « IT news, forums, messages
Re: Sort of Dynamic Image generation - Problem

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация