Capture text between tags

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
zippee
Forum Newbie
Posts: 9
Joined: Wed Jun 22, 2005 6:28 am
Location: England

Capture text between tags

Post by zippee »

Hi, is there any php function can read text between tags or quotes.

For example, I have <h1>This is heading 1</h1> and "This is text in Quote", how can I use php to read the text between <h1></h1> tags or the text between quotes? I know I can use substr but is there any function that can directly read the text?
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

you are going to have to use a regular expression probably, you could use somtin like turning it all into a array then checking with strpos but that would be real slow and painful to code. just use a regular expression, sorry im not good at them though so i cant write one for you
User avatar
zippee
Forum Newbie
Posts: 9
Joined: Wed Jun 22, 2005 6:28 am
Location: England

Post by zippee »

Which regular expression you mean?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

read through the regex board here... viewforum.php?f=38

everything you need has been talked about in there at some point or another.........
Post Reply