Jump to content

Archived

This topic is now archived and is closed to further replies.

brown2005

numbers

Recommended Posts

say i have

$a = "544";

what i want is to use an image for each number so the 5 would be image5.png and the four image4.png....

but how do i create a function that automatically switches the numbers into images...

Share this post


Link to post
Share on other sites
<img src="<?php echo 'image'.$a.'.png' ?>">


If that's what you ment? or did you want it to be random?

Liam

Share this post


Link to post
Share on other sites
i mean....

i want it to break the 544 down.... so it has an image for each individual number so i only have to have images of number 0-9 ...

Share this post


Link to post
Share on other sites
[code]<?php
$a='544';
$numbers=array('1','2','3','4','5','6','7','8','9','0');
$images=array('<img src="image1.png">','<img src="image2.png">','<img src="image3.png">','<img src="image4.png">','<img src="image5.png">','<img src="image6.png">','<img src="image7.png">','<img src="image8.png">','<img src="image9.png">','<img src="image0.png">');
$b=str_replace($numbers,$images,$a);
echo $b;
?>[/code]
Tested and working :)

Take it your using it for counter or date and time or somthing? I use to use the same for a counter back in the day :)

Liam

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.