require_once('UrlTitle.php'); $url = 'https://en.wikipedia.org/wiki/Main_Page'; $title = UrlTitle::getUrlTitle($url); echo $title;
require_once('UrlTitle.php'); $urls = array( 'https://www.google.com/', 'https://www.facebook.com/', 'https://www.youtube.com/' ); foreach ($urls as $url) { $title = UrlTitle::getUrlTitle($url); echo "$url - $title\n"; }
require_once('UrlTitle.php'); $url = 'https://www.amazon.com/Echo-Dot-3rd-Gen-Smart/dp/B07FZ8S74R'; $metadata = UrlTitle::getMetadata($url); print_r($metadata);This code will output an array containing the metadata of the Amazon Echo Dot 3rd Generation product page, including title, description, and image URL. Package/library: PHP URL Title In summary, PHP URL Title is a useful library that can help you extract the titles of webpages and also extract metadata from them. It is a package/library that is easy to use and can save you a lot of time and effort when working with webpages.