Remove line from file
Hello alliedmoders :),
As what i typed in the title, iam try to remove line from the file. I created a vip system and i want to add option for remove who has date expired and i have searched for how to do that and found some ways and i used one that recommend by HamletEagle but i got an issue and don't know how to fix it PHP Code:
Another question: Is it possible to do that by using "TrieDeleteKey" ? |
Re: Remove line from file
If you're trying to remove entries based on the timestamp, maybe consider using nvault since it has a built in mechanism to prune the data based on timestamps.
|
Re: Remove line from file
Quote:
I tried to use stock that i mentioned in the first post: Code:
It's work like create a new file without line of the user who expired and delete old file and rename the new file but as you see the old file didn't deleted etc.. https://i.ibb.co/6BLJfHs/Test.png I'm not sure if i can do that using "TrieDeleteKey" but tried and it did not work: PHP Code:
|
Re: Remove line from file
TrieDeleteKey() will remove the item from the trie, not the actual file. You must recreate the entire file in order to remove a line.
Not sure what's exactly wrong in your code, but I can offer you a "cleaner" way of doing it. Instead of making a temporary file, renaming and deleting it, store all lines of your file in a dynamic array when reading it, EXCEPT the lines that are already expired. Then, after closing the file, open it again in write mode, loop through the array and write all lines. Pseudo-code: Code:
|
Re: Remove line from file
I tested your code but i got a warrning message while complie the plugin in this line:
PHP Code:
Quote:
|
Re: Remove line from file
Try removing the +1 in the loop.
Code updated. |
Re: Remove line from file
Quote:
Exmaple: Quote:
Quote:
|
Re: Remove line from file
Simply check for that symbol and make an exception?... You already have a code that checks if it is a comment - store the comments in the array too.
|
Re: Remove line from file
Quote:
Thank you :) |
| All times are GMT -4. The time now is 11:43. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.