|
-
Feb 24th, 2003, 12:19 AM
#1
Thread Starter
Addicted Member
flat file reading backwards
hi
i'm appending some text to a flat file (.txt), but when i read it, i only want to read the last 5 lines. i can read the file fine forwards.
is there a way to append the text to the top, or is there a way to read it backwards (last text first)
--770
-
Feb 24th, 2003, 03:49 PM
#2
Frenzied Member
how are you appending to it? if you jsut open it and write to it I think by default it goes to the end.
-
Feb 24th, 2003, 07:22 PM
#3
Thread Starter
Addicted Member
yes, i'm just opening it and i know by default it puts it at the bottom, but is there a way to just get the bottom 5 lines??
--770
-
Feb 24th, 2003, 07:58 PM
#4
Frenzied Member
yes you can, but if you get just the 5 bottom lines then it will erase all the others lines.
once you find the amount of lines you can subtract 5 and then just delete the rest of them. can't imagine why you want only the last five lines if you keep adding to it. also it depends on what the seperater is, a , or a ; or a |
-
Feb 24th, 2003, 09:37 PM
#5
Thread Starter
Addicted Member
well it's for a shout box. i could use mysql but i don't have it installed.. i'm running the server off my computer.
but i don't have to delete the other lines do i .. i just have to read the file to get the number of lines, and then read it again to get the last 5..
but i'm not sure how to code that.. (to get the number of lines and to get the total lines - 5) appreciate any help..
thanx
--770
-
Feb 24th, 2003, 11:31 PM
#6
Frenzied Member
what are you going to do with those five lines? when you get them
-
Feb 24th, 2003, 11:45 PM
#7
Thread Starter
Addicted Member
well i just want to post the latest 5 shouts...
i know this would be a lot easier with mysql....but my only concernt is when i move the site to a server, will i be able to copy the database to their server? because i don't want to loose the info.
--770
-
Feb 25th, 2003, 12:29 AM
#8
Frenzied Member
yes you can backup db or copy the db to the new server.
to find the total length of a file (total lines ) you do this
$fileread = fopen("file.txt", "r");
$arrlen = count($fileread);
count will count all the lines. tha tshould be wha tyou are looking for. or you could put each line into an array and count it that way.
-
Feb 25th, 2003, 01:09 AM
#9
Thread Starter
Addicted Member
thanx.....i'll use that for now
but i also downloaded mysql and installed it.....but i was wondering if there is any graphical utility i could you to add/modify tables quickly. i've used myphpadmin or something like that on a server, but i can't find one i can you on my computer with iis.....
i tried the one off the mysql website mysql control center, but that was terrible..are they anyothers that are better??
thanx
--770
-
Feb 25th, 2003, 08:47 AM
#10
Frenzied Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|