RoninStretch Posted April 29, 2007 Share Posted April 29, 2007 Now i know this is possible with libraries etc but I'm still new so I don't know enough to get involved with that yet. However I have a small site where users sign up and can earn/spend points. I display the users points in the top of every page but atm it looks really bland. So i created ten images..numbers 0-9. When put next to each other these images should sit together to look like one number..The points can go upto the millions. Of course the problem is how to decide which image/number to place and how??? I don't know what's possible with php but is there a way so that, for example if our points value is 43012, I can find out how long the number is? i.e how many characters long? Then find the first number is 4 so display image_4.gif, second number is 3 so display image_3.gif and so on? Any links to relevant reading or advice will be hugely appreciated. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/49214-solved-displaying-images-in-place-of-a-number/ Share on other sites More sharing options...
php_joe Posted April 29, 2007 Share Posted April 29, 2007 <? $score = '43012'; $number = preg_split('//', $score, -1, PREG_SPLIT_NO_EMPTY); $count = count($number); // <<<< if you need to know how many char in the number (no purpose here) foreach($number as $value){ echo "<img src=\"./{$value}.jpg\">"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/49214-solved-displaying-images-in-place-of-a-number/#findComment-241157 Share on other sites More sharing options...
AndyB Posted April 29, 2007 Share Posted April 29, 2007 Or: <?php $number = "43012"; // for example for ($i=0;$i<strlen($number); $i++) { echo "<img src='image_". $number{$i}. ".gif'>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/49214-solved-displaying-images-in-place-of-a-number/#findComment-241160 Share on other sites More sharing options...
RoninStretch Posted April 29, 2007 Author Share Posted April 29, 2007 Marvelous!!! Thanks a lot both of you. *sends love* Quote Link to comment https://forums.phpfreaks.com/topic/49214-solved-displaying-images-in-place-of-a-number/#findComment-241162 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.