Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

search str for text

Status
Not open for further replies.

MJB3K

Programmer
Jul 16, 2004
524
0
0
GB
Hi, how would i go about getting the title text from a page.

e.g. i am opening pages to get the source code, i want to be able to get the title of the page. say if the str was:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
 <title>PHP: Hypertext Preprocessor</title>
.. more body text here
How would i be able to get the PHP: Hypertext Preprocessor from the str and assign it to a var?

Any ideas??


Regards,

Martin

Computing Help And Info:
 
Forgive me if this isn't as optimal as it could be...

Code:
$mydata = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">';
$mydata .= "\r\n";
$mydata .= '<html>';
$mydata .= "\r\n";
$mydata .= '<head>';
$mydata .= "\r\n";
$mydata .= '<title>PHP: Hypertext Preprocessor</title>';
$mydata .= "\r\n";
$start = strpos($mydata, '<title>') + 7;
$end = strpos($mydata, '</title>') - $start;
[b]echo substr($mydata, $start, $end);[/b]

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
I think the original poster means different pages with different titles.

You should look into regular expressions: preg_match(), ereg(), etc...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top