Find a title with php
Moderator: General Moderators
Find a title with php
Is it possible to find a title with a form where you submit an url (f.i. "viewtopic.php?f=1&t=100407"). When pressing submit, it should echo the text between "<title>DevNetwork Forums • " and "</title>".
Re: Find a title with php
Not quite sure what you mean....
Can you explain a bit more about what you want to achieve?
Can you explain a bit more about what you want to achieve?
Re: Find a title with php
Code: Select all
<?php
if($_POST['submit']) {
/*
Find $_POST['link']'s title (only the text between "<title>DevNetwork Forums • View forum - " and "</title>" (if viewforum.php?f=1 were the url, it should echo 'PHP - Code'.
*/
echo $title;
} else {?>
<form enctype="multipart/form-data" action="" method="post">
<input name="link" type="text" /><br />
<input name="submit" type="text" />
</form>
<?php
}
?>Re: Find a title with php
Yes you can do this.
Pass the text in between the <title> </title> tages into a variable.
Then use the PHP explode function to split the string into smaller strings.
All you need to do then is call the appropriate exploded string that contains the part of the title you need.
Pass the text in between the <title> </title> tages into a variable.
Then use the PHP explode function to split the string into smaller strings.
All you need to do then is call the appropriate exploded string that contains the part of the title you need.
Re: Find a title with php
But how do I make the sciript check the url's title?
Re: Find a title with php
Code: Select all
<?
$url=file_get_contents("http://www.devnetwork.net");
preg_match('/<title>(.*)<\/title>/i',$url,$output);
echo "Page title: \"".$output[1]."\"";
?>