homepage Welcome to WebmasterWorld Guest from 54.205.241.107
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
string parsing
ideal way of parsing string from a text file
copongcopong

10+ Year Member



 
Msg#: 2774 posted 11:49 pm on Feb 4, 2004 (gmt 0)

is there a fastest and most efficient way of parsing text from a file using php's built in function?

the file contains data delimited by some character like '&' and by new lines. i use the "file" function to convert the lines into array then use foreach to read each line then use "parse_str" to get the data i need.

anyone have a faster way of doing this or dealing with such? thanks.

 

jatar_k

WebmasterWorld Administrator jatar_k us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 2774 posted 6:41 pm on Feb 5, 2004 (gmt 0)

I don't usually use file. I usually read line by line and process that way. As with most parsing tasks, you have to be familiar with the type and amount of data to be sure that your method is the most efficient.

Most of my parsers are for various types of logs and the amount of data can be overwhelming. I never use file because the thought of loading 500K lines into an array always makes my servers cry a little. ;)

copongcopong

10+ Year Member



 
Msg#: 2774 posted 7:39 pm on Feb 5, 2004 (gmt 0)

thanks for your insight. do you use fgetcsv? or other? please let me know so that I could personally try it and compare the speed. Thanks again.

jatar_k

WebmasterWorld Administrator jatar_k us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 2774 posted 9:15 pm on Feb 5, 2004 (gmt 0)

fgetcsv
fgets
fgetss
fread

it all depends on what type of data you are working with

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved