homepage Welcome to WebmasterWorld Guest from 23.20.34.25
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Website
Visit PubCon.com
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




msg:1303802
 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




msg:1303803
 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




msg:1303804
 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




msg:1303805
 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.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved