Method to extract certain data from a string

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
voltrader
Forum Contributor
Posts: 223
Joined: Wed Jul 07, 2004 12:44 pm
Location: SF Bay Area

Method to extract certain data from a string

Post by voltrader »

I'd like to pick up a sequence of numbers from a string of HTML.

The numbers always follow a certain sequence of HTML, say:

<unique html>hello</unique html>NUMBERS I WANT</td><more unique html>2nd GROUP OF NUMBERS I WANT</more unique html>

How can I then parse the string to extract the numbers I want, assuming that I can identify a bit of unique html before the numbers?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Well, there's "2 × strpos() + substr()" or regex.
User avatar
voltrader
Forum Contributor
Posts: 223
Joined: Wed Jul 07, 2004 12:44 pm
Location: SF Bay Area

Post by voltrader »

Thanks feyd.

I think it'll be strgpos() and substr() then :-D

Regex is the dark arts.
Post Reply