homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

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

 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.



 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. ;)


 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.


 9:15 pm on Feb 5, 2004 (gmt 0)


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