I made this small composer package based on the top answer: https://github.com/diversen/get-meta-tags
composer require diversen/get-meta-tags
And then:
use diversen\meta;
$m = new meta();
// Simple usage, get's title, description, and keywords by default
$ary = $m->getMeta('https://github.com/diversen/get-meta-tags');
print_r($ary);
// With more params
$ary = $m->getMeta('https://github.com/diversen/get-meta-tags', array ('description' ,'keywords'), $timeout = 10);
print_r($ary);
It requires CURL and DOMDocument, as the top answer - and is built in the way, but has option for setting curl timeout (and for getting all kind of meta tags).