Because we'll be using the length of the variable $count more then once, we might as well set it as a variable. We also have to get the height and width of the image we'll be using.
<?
$path = '/home/www/counter/images/';
$ending = '.GIF';
$default_style = 'GOLD';
$style = ($style)?$style:$default_style;
$size = GetImageSize($path. '1'.$style.$ending);
$length_count = strlen($count);
$width = $size[0];
$height = $size[1];
?>
Now that all the variables are set, it's time to begin creating the image. We are creating an image that has the width of one of our digits multiplied by $length_count. The height remains as $height (the length of $count will never change the height of the image).
Now the hard part begins. As with our last script, this one must loop through every digit in $count, outputting its corresponding every time. First, we need the loop.
We must declare each digit that we're using. The easiest way to do this is to put them all into the array $im_input[]. So if the number we wanted to print out was "100", we would need one $im_input[1] and two $im_input[0]. But since we're using the same digit, it seems rather pointless to declare the same digit twice. To stop this from happening, we can simply put an if() clause in our script. It simply says , "If the variable $im_input[current_digit] doesn't exist, then create it using the $path, $style, and $ending values that we've already set."
Now all we have to do is to output the image. Because this isn't an HTML page, the proper headers must be sent. Also, to clear up memory, it's a good idea to delete the image after it's outputted.