Código PHP:
<?php
//create a file called counter.txt and upload it to your server
//now open the file
$fp = fopen("counter.txt" , "r");
//read in the current count
$count = (int)fread($fp, 1024);
//increment the count by 1
$count++;
//close the file
fclose($fp);
//image display, get the lentgth of the count
for ($i = 0 ;$i < strlen($count) ; $i++)
{
$imgsrc = substr($count,$i ,1);
//display the image(s) note our images are in a folder located at
//images/count1/ change this to your location
echo "<img src =\"/contador/count/01/" . $imgsrc . ".gif\">";
}
//open the counter file
$fp = fopen("counter.txt", "w");
//write the new count to the file
$count=sprintf("%05d",$count);//PRUEBA ASI
fwrite($fp, $count);
//close the file
fclose($fp);
A VER SI TE SIRVE