473,379 Members | 1,544 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Sort of Dynamic Image generation - Problem

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

Jul 17 '05 #1
1 2011
du***********@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 ?
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: bissatch | last post by:
Hi, I am using the following code to generate images online: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled Document</title> <meta...
11
by: Marco Loskamp | last post by:
Dear list, I'm trying to dynamically generate functions; it seems that what I really want is beyond C itself, but I'd like to be confirmed here. In the minimal example below, I'd like to...
3
by: moondaddy | last post by:
I read a great article by Dino Esposito about a control he built to help generate images dynamically similar to how asp.net 2.0 will do it. His sample worked in a C# project, but when I tried to...
0
by: pbb | last post by:
I saw an old post where a guy (Moondaddy) converted Dino Esposito's code for dynamically generating an image in ASP.NET 1.1 from C# to VB. The basic gist of the code is that you can stream an...
15
by: Nospam | last post by:
Is there a tutorial on dynamic SID generation?
0
by: rockdale | last post by:
Hi, All: I dynamic add an arrow up/down image in OnItemDataBound event for my datagrid, it works fine. But I have another textbox which trigger postback and doing something, after this event get...
2
by: Ghada Al-Mashaqbeh via DotNetMonster.com | last post by:
Hi all, I am facing a problem in dynamic code generation at run time, the problem occurs when the dynmaic code use global data exist within the original application. Lets say that my...
0
by: Cliff Smith | last post by:
Hi Group, In doing a website for a stamp maker, I have come across the following problem. I have a file called image_generator.php that creates a preview of the stamp. This uses GET vars for...
7
by: dino d. | last post by:
Hi- I want to create a dynamic image with areas so that when the user clicks different areas, the user jumps to those pages. The problem is, I can't seem to figure out how to do this efficiently....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.