954,597 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Capture text between tags

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

For example, I have This is heading 1 and "This is text in Quote", how can I use php to read the text between tags or the text between quotes? I know I can use substr but is there any function that can directly read the text?

zippee
Posting Whiz in Training
294 posts since Jan 2005
Reputation Points: 10
Solved Threads: 7
 

zippee,

I would also like to know how to do this.
---
I don't know the answer, but I think I was looking for the exact same thing. I wanted a php script that would visit http://www.whatismyip.com and extract my IP address which was written in the HTML as follows: Your IP Is xxx.xxx.xxx.xxx

Is this similar to what you're looking for?

J_

J_Search
Posting Whiz in Training
285 posts since Aug 2005
Reputation Points: 27
Solved Threads: 6
 

No. Your application can be solved using substr alone.

What I try to do is when I use fget() to read a file or a webpage, I can retrieve text in heading. For example, when I used fget("http://www.whatismyip.com") to read the web page, I can get Your IP - xxx.xxx.xxx.xx. What I want to do is the php script can read "Your IP - xxx.xxx.xxx.xx" directly for me and stored in db. But since I'm not only want to read the heading text, but also etc, I have to write many line to retrive each data. If there is any function can read something within a specifc tags (say between or ) then it would be great.

Anyone?

zippee
Posting Whiz in Training
294 posts since Jan 2005
Reputation Points: 10
Solved Threads: 7
 

zippee, you'll want to learn how to use Regular Expressions in PHP. You can find a good Regular Expression tutorial that includes examples for what you are wanting here .

chrisbliss18
Posting Shark
917 posts since Aug 2005
Reputation Points: 38
Solved Threads: 25
 

That's what I want... Thanks chris. I also found http://www.amk.ca/python/howto/regex/regex.html from google search which may be useful to others.

zippee
Posting Whiz in Training
294 posts since Jan 2005
Reputation Points: 10
Solved Threads: 7
 
digital-ether
Nearly a Posting Virtuoso
Moderator
1,293 posts since Sep 2005
Reputation Points: 461
Solved Threads: 101
 

Thank you so much, it saved a lot of time for me.:cool:

tahiryasin
Newbie Poster
1 post since Aug 2011
Reputation Points: 10
Solved Threads: 0
 

Thank you very much, it saved a lot of time for me too.

jpdeleon
Newbie Poster
5 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You