I am trying to extract all meta tags in web page, currently am using preg_match_all to get that, but unfortunately it returns an empty strings for the array indexes.
<?php
$meta_tag_pattern = '/<meta(?:"[^"]*"[\'"]*|\'[^\']*\'[\'"]*|[^\'">])+>/';
$meta_url = file_get_contents('test.html');
if(preg_match_all($meta_tag_pattern, $meta_url, $matches) == 1)
echo "there is a match <br>";
print_r($matches);
?>
Returned array:
Array ( [0] => Array ( [0] => [1] => [2] => [3] => ) ) Array ( [0] => Array ( [0] => [1] => [2] => [3] => ) )