CancelImage Upload

How to read a websites meta tags with php's get_meta_tags() function

If you are building a site indexing website that needs to scan a page's title and meta tags the PHP function get_meta_tags() is the thing that dreams are made out of. Sure, you could write a bunch of regular expressions to extract meta tags and all their information from a website. But then again you could save yourself the time and practice your gloating face instead!

So, how does get_meta_tags() work? Well, it is not really rockets science. All you need to do is specify the website address that you wish to scan, and PHP will take care of the rest itself.

The various meta tags will be loaded into array, including components such as: title, author, publisher, copyright, keywords, description, page-topic, language, robots, audience, netinsert, y_key, verify-v1 and msvalidate_01.

Here an example of how to load the meta tags via get_meta_tags() and to output each:

<?php

$meta = get_meta_tags("http://www.example.com");

while(list($key, $value) = each($meta))
{

       echo "<b>".$key."</b>: ".$value."<br>";

}


?>


Login
Want to leave a comment?

No problem. Just enter your email and password below.


register | home | reminder

myDesignTool Networking • www.mydesigntool.cominfo@mydesigntool.com