Retrieve data from text file php




















Learn more. Read a plain text file with php Ask Question. Asked 11 years, 2 months ago. Active 27 days ago. Viewed k times. I have a text file with this information in my server: Data1 Data2 Data3. Improve this question.

ZygD 9, 35 35 gold badges 58 58 silver badges 76 76 bronze badges. Add a comment. Active Oldest Votes. Do your work with the line Improve this answer.

Community Bot 1 1 1 silver badge. Payload Payload 1, 1 1 gold badge 9 9 silver badges 6 6 bronze badges. I assume this will "explode" your memory with a very large dataset — Jonathan. This is handy, but note: each line has new line character at end :D — s-t. Taz 3, 2 2 gold badges 34 34 silver badges 55 55 bronze badges.

Ullas Prabhakar Ullas Prabhakar 3, 3 3 gold badges 26 26 silver badges 27 27 bronze badges. Continues doing this until it is the end of file, and then closes the file. DaiYoukai DaiYoukai 1, 11 11 silver badges 9 9 bronze badges. BrokenBinary 6, 3 3 gold badges 44 44 silver badges 52 52 bronze badges. Svinjica Svinjica 1, 1 1 gold badge 30 30 silver badges 57 57 bronze badges. Vivz 6, 2 2 gold badges 16 16 silver badges 33 33 bronze badges. EDIT: Fixed a minor bug.

Added some style to make it easier on the eyes. Made it cross browser compatible. I strongly encourage you to get acquainted with MySQL. I have found it to be much simpler than PHP. MySQL is nothing more than a glorified spreadsheet. Working around MySQL will make coding much more difficult. For example I can have 50 pages that are very similar. In 15 seconds or much less I can update all 50 pages.

It's a lifesaver really. You surely took some time to do this and it works very well. Major thanks! I have however come across a small problem. As you can see on the sample data there are sometimes two values for an identifier. They are further more preceded by -1 or 0 in front of them. The minus one is for previous year and the 0 for current year Trying to understand you code and will give it a try myself.

Thanks Kev. I think I can do what you are asking, but I am not all that sure what you are asking ; Can you give me a detailed explanation of what the program is supposed to do? For example, what do you want to type in that will identify the particular number that you are looking for? How many figures will you be adding together? Willl there be other calculations, if so, how will they be performed. Any other details besides the question I just asked would help me a lot.

Especially the ones I asked you in my earlier posts. I had a lot of fun with it and learned lots along the way as I created the script : I do hope you read my posts above as they have some links to useful threads and also important questions I notice you have not answered yet.

I agree with you a database would be more natural but I prefer to avoid this. In the end I want to use the numbers extracted from the text file in any way I want subtract, multiply etc So a function that will get the number based on these three identifiers.

Based on the example text file extract below, function UB,0, would return the number I may be a bit slower getting it updated, because I have three tests this week that I am in the middle of and have been running low on sleep. Who all will be using this program? This will help me to account for possible typos and errors. I am no expert, but isn't the code snippet you just posted do the same thing as my script? Just out of curiosity, how large are these text documents that we are talking about?

EDIT: updated the above script to search based on col1 - col3. Most likely, a member posted a link a long time ago to a web page that has since been removed. It's also possible that there was a typo when posting the URL. We redirect you to this notice instead of stripping out the link to preserve the integrity of the post.

Answered by urtrivedi in a post from 9 Years Ago. GOT IT!! Enjoy my code! Newbie Mike. Facebook Like. Twitter Tweet. Be a part of the DaniWeb community.



0コメント

  • 1000 / 1000