PHP Questions Home | Register | Login
Categories
Arrays
Files
Forms
Creating PDFs
PHP Errors
Functions
Images
MySQL
Numbers
Others
Strings
Website
Unanswered

PHP Forums
Forums Index
MySQL Forum
PHP Forum
Flash/Actionscript
Javascript
Web design

More PHP
PHP Functions
Top Questions
Ask a Question
PHP Interview Questions
PHP Jobs
Ecommerce
IT Questions
Business Websites

Sponsors

sponsor ad
My Salary
PHP Developer Salary
Advertise Here

How do I fetch the meta tags from a webpage using PHP?


Believe it or not, there is actually a built in PHP function to do this for you so you don't have to write your own parser or get down to looking at certain regular expressions in order to extract the relevant information from the page.

So here is how this function works practically.

Let's say we wanted to get the information for the PHP Questions homepage, then all we do is the following:

<?php
$gettags 
get_meta_tags('http://www.php-questions.com/');

foreach(
$gettags as $i => $v) echo "$i - $v \n\n";

//outputs: description - PHP Questions contains a range of common questions and answers related to various aspects of PHP...

//keywords - php,questions,answers,php faq

?>


Note that, if available, this will also return the 'author' and 'geo_position' information for a webpage.



Comment on this Question and Answer >>>

ASK A QUESTION

More strings PHP Questions

How do I format the output of a string?

How do I break email address into username and hostname?

How do I make the contents of a string upper case?

How do I escape a string with slashes?

How do I remove trailing whitespace?



Custom Search