Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 4th, 2013, 11:48 PM   #1
origamiguy
Programmer
 
Join Date: Jan 2013
Posts: 55
Rep Power: 5 origamiguy is on a distinguished road
best way to parse text files

is there a best way to parse text files?

i imagine the use of something like:

$txt = get_file_contents(somefile.txt);
$txt_array = explode($txt,'|');
foreach($txt_array AS $record){
$element = $txt_array = explode($record,';');
// do something with each element
}
//clear up variables

is this good code or is there a proven better way? i do need to use each data field individually....

thanks
origamiguy is offline   Reply With Quote
Old Sep 5th, 2013, 5:44 AM   #2
pritaeas
mod_pritaeas
 
Join Date: May 2009
Location: The Netherlands
Posts: 251
Rep Power: 8 pritaeas is on a distinguished road
Re: best way to parse text files

Depends on what your file holds, but there is nothing against using the above.
pritaeas is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
processing massive text files bonecone Software Design and Algorithms 7 Jan 5th, 2013 7:48 PM
Script that converts text files to html files Crimmm Bash / Shell Scripting 2 Mar 4th, 2011 1:43 AM
DOS batch file to FTP download files by reading from the text file. Abhijat_PF Other Programming Languages 1 Sep 14th, 2010 3:48 PM
C++ read text files flair999 C++ 6 Jul 20th, 2009 12:00 PM
Repetitive replacing sections of text files Novice Other Scripting Languages 2 Jun 17th, 2005 10:07 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:03 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC