Re: [PHP4BETA] re:Incremnting a number in a file

From: Date: Fri, 04 Feb 2000 07:01:07 +0000
Subject: Re: [PHP4BETA] re:Incremnting a number in a file
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-9788@lists.php.net to get a copy of this message
On 4 Feb, Joseph H Blythe wrote: > Evan Klinger wrote: > >> The mode "w+" does indeed open the file for reading and writing; >> however, it truncates the file if it already exists and positions the >> stream at the beginning of the file. You would want to use mode "r+" >> which opens for reading and writing but does not truncate the file. > > Doh! I didn't even think of that he he, but this still does not do what I > intended I want to read the value 0 and increment it by one every time so it > would go 0, 1 , 2, 3 etc... not so it appends it to the end of the number, if > I use the w+ it still equals NULL? > > thanks. > > Joseph H Blythe > > Boldweb Internet / Binary Logic > 257 Churchill Road Prospect, > Adelaide South Australia 5082 > > PH: 08 8342 0022 > FAX: 08 8342 0155 > > mailto:webdevel@binarylogic.com.au > Open file for read, get the value and increment it, close the file, open file for writing and write out the new value? This should replace the old value with 'old value++' - I'll leave the code as an exercise for the reader:-). There is probably a better way.... Cheers -- David Robley | WEBMASTER & Mail List Admin RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/ AusEinet | http://auseinet.flinders.edu.au/ Flinders University, ADELAIDE, SOUTH AUSTRALIA

« previous php.version4 (#9788) next »