We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
php title help
Topic Started: Mar 30 2005, 03:30 PM (259 Views)
kingy
1 in 10 people understands binary, the other 1 doesn't
[ *  *  *  *  *  * ]
Hi

Is their any way for php to obtain the page title of a completely different website, other than itself.

If anybody can help i am very grateful

Kingy
Offline Profile Quote Post Goto Top
 
Gornakle
Member Avatar
Member
[ *  *  *  *  * ]
Code:
 
<?php

$html = file_get_contents("http://www.someurl.com/somefile.htm");
if( preg_match( "#<title>(.+?)</title>#i", $html, $matches) ) {
 $title = $matches[1];
}
else {
 // Aw.. no title
}

?>


There you go. Note that not all sites allow you to check their source code through PHP.
Offline Profile Quote Post Goto Top
 
kingy
1 in 10 people understands binary, the other 1 doesn't
[ *  *  *  *  *  * ]
thankyou very much, it works fine for my purposes
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Technology Chat · Next Topic »
Add Reply