Jump to content

Recommended Posts

  • 2 weeks later...

Well u need the images of the numbers

I came up with this code

<?php

// Get and update our counter
$counter=(file_exists('counter.txt') && (($counter=file_get_contents('counter.txt'))>0))?$counter+1:1;
file_put_contents('counter.txt',$counter);

// Max Numbers to appear on counter
define('MAX_NUMBERS',3);

// Pad Counter with 0's
$counter=substr(str_repeat('0',MAX_NUMBERS).$counter,-MAX_NUMBERS);

// Get Number Images Attributes (Width & Height)
$iinfo=getimagesize('pics/0.gif');

$cw=$iinfo[0];
$ch=$iinfo[1];

// Calculate Max Width
$iw=$cw*MAX_NUMBERS;

// Create image canvas for counter
$ci=imagecreate($iw,$ch);


// Loop to get image of each digit
for($i=0;$i<MAX_NUMBERS;$i++)
{
   // Grab Next Number in $counter
   $num=substr($counter,$i,1);
   // If Number use number image otherwise blank
   $num=ctype_digit($num)?$num:'blank';
  // Do We have the image already?
   if(!isset($images[$num]))
       // No, Load the image
     $images[$num] =  imagecreatefromgif("pics/{$num}.gif");
   // Place image in correct place on new counter image
   imagecopy($ci,$images[$num],$i*$cw,0,0,0,$cw,$ch);
}

// tell browser we displaying a gif
header('Content-type: image/gif');

// Show our image
imagegif($ci);
?>

 

See nothing to it, just make shure gd2 extension is loaded.

 

Well up to u to take this and make it better :)

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.