Jump to content

Extracting a value from a page of text...


techusky

Recommended Posts

I'm normally fairly proficient with PHP, but I haven't done any coding in quite a while, so I'm a little rusty.

 

I have an entire page of text from which I need to extract a single value. Here is a small portion of the page in question:

 

Total Rank: 128
Total Points: 4,978
Next Rank: 20

 

For instance, I need to extract the values "128" "4978" and "20" and store them in variables. These values change all the time, so I'm not sure what the best way to go about this is... maybe a regular expression  :shrug:? If that's the case, I've never been too good with them, so any help would be appreciated.

Link to comment
Share on other sites

UPDATE: I accidentally included the wrong lines in my first post. The values I am trying to obtain do not have the colon next to them as I previously alluded to. Sorry for the confusion. The actual values I am trying to obtain are listed below: "1,799,447" "2,505,648,676" and "570,552,255". These three values correspond to "Points Earned" "EXP Donated" and "Credits Given", respectively.

 

I do not have access to the code that generates the text I am trying to sift through. What I'm doing is copying all the text on the page, dumping it into my own PHP script through a form and parsing through it. Here is the full text:

 

Steve™

Points Earned
1,799,447    EXP Donated
2,505,648,676    Credits Given
570,552,255


Repair Points Donated
13,163    Posts Made
13,145    Members Recruited
306


Item Flow
Item    Amount Donated    Given From Guild    Net Change
Byte    171    9    162
Mana    0    10,000    -10,000
Ruby Herb    0    5,000    -5,000
Syn    0    1,333    -1,333
Taistelu    900    800    100

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.