Ver Mensaje Individual
  #9 (permalink)  
Antiguo 11/09/2003, 13:29
josemi
Ex Colaborador
 
Fecha de Ingreso: junio-2002
Mensajes: 9.091
Antigüedad: 21 años, 10 meses
Puntos: 16
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($fp1024);

//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 ;$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.
__________________
Josemi

Aprendiz de mucho, maestro de poco.