1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
function get_meta_data($url, $searchkey='') {
print "<h1>$url</h1>";
$data = get_meta_tags($url); // get the meta data in an array
foreach($data as $key => $value) {
$value = strtr($value, get_html_translation_table(HTML_ENTITIES)); // mask the content
if($searchkey != '') { // if only one meta tag is in demand e.g. 'description'
if($key == $searchkey) {
$str = $value; // just return the value
}
} else { // all meta tags
$pattern = '/ |,/i'; // ' ' or ','
$array = preg_split($pattern, $value, -1, PREG_SPLIT_NO_EMPTY); // split it in an array, so we have the count of words
$str .= '<p><span style="display:block;color:#000000;font-weight:bold;">' . $key . ' <span style="font-weight:normal;">(' . count($array) . ' words | ' . strlen($value) . ' chars)</span></span>' . $value . '</p>'; // format data with count of words and chars
}
} |
Partager