Raised This Month: $ Target: $400
 0% 

How to get counter on txt?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 06-10-2018 , 13:26   Re: How to get counter on txt?
Reply With Quote #1

Simplest way is to write in a new line every time.

Then loop fgets to retrieve the data, and count it or w/e you need to do with it.

EDIT: Oh i misunderstood what you are trying to do ( you wan't to delete the previous input and not leave it )

Thats even easier, you should still retrieve it with with fgets or w/e then close the file and use

PHP Code:
fopensFilename"wt" ); 
( This function with flags wt, deletes the content of the file ( if it exists ) and opens it for writing, also returns a handle )

Use what you retrieved previously to print whatever you need into the file

Also its good practise not to use read_file and write_file, thats why I didn't, but it would be fine to use those in your case, if you want to.

Last edited by maqi; 06-10-2018 at 13:35.
maqi is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:32.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode