Forum Moderators: coopster
I have a PHP variable called $tname.
Lets say $tname="Norma";
Right now I have it setup to output this:
<p><?php echo($tname);?></p>
Which turns into:
<p>Norma</p>
But what I would really like to output is this:
<p><img src="/font/caps/n.gif"><img src="/font/o.gif"><img src="/font/r.gif"><img src="/font/m.gif"><img src="/font/a.gif"></p>
To confound this issue even more, $tname can be any length and the first character is not always capitalized, nor is it the only one that can be capitalized.
Any ideas how I can go about dong this?
Thanks
//strip characters you do not want here
$length = strlen [us3.php.net]($tname);
echo '<p>';
for($i = 0; $i < $length; $i++) {
if(ctype_upper [us3.php.net]($tname[$i]) { echo '<img src="/font/caps/'.strtolower [us3.php.net]($tname[$i]).'.gif" />'; }
else { echo '<img src="/font/'.$tname[$i].'.gif" />'; }
}
echo '</p>';
Something like this (not tested). I wouldn't suggest using a large amount of font for this. Good luck!
<?php
$tname = "Norma";
$varToLower = strtolower($tname);
$length = strlen($varToLower);
echo "<p>";
for( $i = 0; $i < $length; $i++) {
echo "<img src=\"/font/caps/$varToLower[$i].gif\" alt=\"$varToLower[$i]\">\n";
}
echo "</p>";
?>
You might look at page counter scripts. Seems like a pretty similar function, except counters only have 10 characters to deal with and you have 62.
Nutter, I'll have to take a look into that. I know that using five+ separate images will definitely cause my sight to slow down on this one page, but I thought having a image generator would use a lot of system overhead. I'll have to look into that.
Thanks.