Hola,
El codigo de Jordi1 no funciona porque al hacer el fread() convierte la cadena con 0 a un entero con el cast (int), que elimina los ceros. Podria solucionarse haciendo el sprintf() justo despues de incrementar el contador:
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++;
$count=sprintf("%05d",$count);//PRUEBA ASI
//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
fwrite($fp, $count);
//close the file
fclose($fp);
?>
Prueba y cuentanos.
Suerte.