Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 3rd July 2007, 23:30
edge edge is offline
Moderator
 
Join Date: Dec 2005
Location: The Netherlands
Posts: 2,036
Thanks: 268
Thanked 152 Times in 132 Posts
Default PHP, read values from txt file, and add

It's me again, with for some people here probably an easy thing to code.

I have this txt file, with in it "tags" with a number value that I need to add up all together.

The parts in the txt file that I need look like this:
Quote:
text text text
<segment bytes="100" number="1">some random text</segment>
text random text random text
some more random text
<segment bytes="3397" number="1">some random text</segment>
some other random text
<segment bytes="3521" number="1">some random text</segment>
<segment bytes="261" number="2">some random text</segment>
<segment bytes="9621" number="3">some random text</segment>
some more random text
some more random text
<segment bytes="7" number="1">some text</segment>
even more text
So. The code needs to read the value after <segment bytes=", and add it all together. (it's always on a new line)
The times that <segment bytes=" is in the file could be one time or many times!

Now. How could I do this the best way?
Any help appreciated!
__________________
Never execute code written on a Friday or a Monday.
Reply With Quote
Sponsored Links
 

Bookmarks

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
PostgreSQL boardmain Feature Requests 56 2nd March 2009 23:24
php on sites not working - fresh install matej Installation/Configuration 2 29th June 2007 19:01
openSuse10.2, ISPConfig, no PHP latcarf Installation/Configuration 22 25th February 2007 14:26
Secure php settings sysconfig Suggest HOWTO 0 4th November 2006 11:11
Howto suggestion suse PhP ver 4 + Ver 5 wwparrish Suggest HOWTO 11 7th August 2006 13:29


All times are GMT +2. The time now is 10:09.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.