Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
newb needs help - getting data from text files
Old 08-18-2006, 12:41 PM newb needs help - getting data from text files
Junior Talker

Posts: 2
Name: jake
Trades: 0
hello everyone,

i am new to the more complex parts of PHP. Is it possible to host a script that will allow a user to scan local text files and take out certain parts of it? i am trying to get item links from a games log file. here is what it looks like ~

1154824696)[Sat Aug 05 20:38:16 2006] \aNPC 13172 Cliffjumper:Cliffjumper\/a says, "Welcome! What can I help you with?"
(1154824700)[Sat Aug 05 20:38:20 2006] Starting broker transaction with Cliffjumper.
(1154824700)[Sat Aug 05 20:38:20 2006] \aNPC 13172 Cliffjumper:Cliffjumper\/a says, "Confound it! Where did I put that ledger? It must be around here somewhere!"
(1154824701)[Sat Aug 05 20:38:21 2006] \#C7CFC708/05/2006 04:52 PM Jacky buys 20 \#FFFFFF\aITEM 1602851716 -119212747:Superior Elixir of Deftness\/a\#C7CFC7 for \#FFEE701g, \#A0A0A083s\/c


the orange part is a piece of a log and the red is a sample of what i want to get out of it and put it in a database. is something like that possible?

any help, links or anything would be great.

thanks
webguy06 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-18-2006, 01:12 PM Re: newb needs help - getting data from text files
cdwhalley.com's Avatar
Skilled Talker

Posts: 75
Trades: 0
That would definately be possible.
First of all, you can read the contents of a .txt file either with the file_get_contents() function, or with this code (taken from the PHP docs) :
PHP Code:
<?php
// get contents of a file into a string
$filename "/usr/local/something.txt";
$handle fopen($filename"r");
$contents fread($handlefilesize($filename));
fclose($handle);
?>
Then, for getting particular parts out of the string, you could would either need regular expressions or some of the PHP string functions - it depends on what criteria you want to take the substring out with.
cdwhalley.com is offline
Reply With Quote
View Public Profile Visit cdwhalley.com's homepage!
 
Old 08-18-2006, 10:10 PM Re: newb needs help - getting data from text files
Junior Talker

Posts: 2
Name: jake
Trades: 0
thanks for the help!

how would i add a progress bar? some of the logs are close to 200mb i would like to show them something so they know it is working.

thanks
webguy06 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to newb needs help - getting data from text files
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11904 seconds with 12 queries