note 24033 deleted from function.fwrite by philip

From: Date: Sat, 19 Oct 2002 17:35:39 +0000
Subject: note 24033 deleted from function.fwrite by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-38300@lists.php.net to get a copy of this message
My grapicaly optimised version : # Builds a basic page counter with graphical interface from a text file! #Credits :george.johnson11@ntlworld.com for the orginal counter #edg@spymac.com for graphical interface # Filename $cnt_file = "counter.txt"; #Check to see if we are being sent a "Reset" request if ($_GET['reset']==1) { #We are, so let's reset the counter #open up the file with write access $tmpfile = fopen($cnt_file,"w"); # Write our $string with 1. (1 not 0 because then the first visitor would be "0") $string = 1; $fp = fwrite($tmpfile,$string); # Close file and close our if fclose($tmpfile); } else { # Read single line into a string $string = implode("", file($cnt_file)); #Get the length of the string for our 'for' loop $length = strlen($string)-1; #Run a for loop to produce the <IMG> tag for the HTML for ($i=0; $i <= $length; $i++) { print ("<IMG SRC=\""); print ($string[$i]); print (".jpg\">"); } # Add one to current value $string++; # Open file for write, not append! $tmpfile = fopen($cnt_file,"w"); # Write the new value back to the string $fp = fwrite($tmpfile,$string); # Close file fclose($tmpfile); } You just need 0-9.jpg of whatever flavour you want. Also now with a neat little reset function. edg

« previous php.notes (#38300) next »