Jump to content

Recommended Posts

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.

 

<?
$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\">";
}
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.