Page 1 of 1

Getting the page title of another page?

Posted: Fri Nov 12, 2010 1:48 pm
by jaceinla
Hi all,

Is it possible to retrieve the page title of another page via php? I'd like to set up a link on PAGE A that points to PAGE B and create it so that:

Code: Select all

<a href="pageB"><?php constant changing title of page B ?></a>
Thanks!

Re: Getting the page title of another page?

Posted: Fri Nov 12, 2010 2:13 pm
by Celauran

Code: Select all

$contents = file_get_contents($pageB);
$title = substr($contents, (stripos($contents, '<title>') + 7), (stripos($contents, '</title>') - stripos($contents, '<title>')));
echo "<a href=\"{$pageB}\">{$title}</a>";

Re: Getting the page title of another page?

Posted: Wed Nov 17, 2010 8:08 pm
by jaceinla
I didn't know file_get_contents can take a URL, thanks.