使用get_meta_tags函数时复制元描述,只需要描述

When echo'ed out instead of just removing all of the other meta tags it seems to be duplicating the description, for example:

BBC has 13 different meta tags, when I echo out just the description in my script it is duplicating it 13 times.

<?php
//make the array 
$TAarray = explode("
", strip_tags($_POST['TAData'])); 

foreach ($TAarray as $key => &$line) {
            $line = trim($line); 
            // get the meta data for each url
            $tags = get_meta_tags($line);

            echo '<tr>';
            foreach ($tags as $meta)        
            {
            echo (isset($tags['description']))?"<br><br       />
Description($line):<br>
".$tags['description']:"<br>
Description($line):<br>
No Meta    Description.";
                    /*echo '<td>' . $meta . '</td>';*/
            }
            echo '</tr>';
    }

    ?>

Here is the URL incase anyone wanted to see it working: http://php-playground.co.cc/testdir/metaex.php

PS

I know the checkboxes are not working they are only there for the layout

I think this is what you are trying to do:

<?php
//make the array 
$TAarray = explode("
", strip_tags($_POST['TAData'])); 

foreach ($TAarray as $key => &$line) {
            $line = trim($line); 
            // get the meta data for each url
            $tags = get_meta_tags($line);

            echo '<tr>';
            echo (isset($tags['description']))?"<br><br       />
Description($line):<br>
".$tags['description']:"<br>
Description($line):<br>
No Meta    Description.";
                   echo '<td>' . $tags['description'] . '</td>';
            echo '</tr>';
    }

    ?>

You'll note that have removed the second for loop.

You are looping over the meta tags, and for each meta tag you are echoing out the description.

Get rid of the loop.

If you use foreach with references, it's good practice to remove that reference after the loop:

foreach ($TAarray as $key => &$line)
{
    $line = trim($line); 
}
unset($line); # remove the reference for safety reasons

But as you don't iterate over $TAarray after that code, the code is superfluous anyway. Don't write superfluous code. I suggest the following:

//make the array 
$TAarray = explode("
", strip_tags($_POST['TAData'])); 
$TAarray = array_map('trim', $TAarray);

And I suggest you put that into a function of it's own:

/**
 * @param string $html
 * @return string[] lines
 */
function getTrimmedTextLinesArrayFromHTMLBlock($html)
{
    $text = strip_tags($html);
    $lines = explode("
", $text);
    $trimmed = array_map('trim', $lines);
    return $trimmed;
}

You can then use it wherever you see fit. You can also test this function independently with different input:

$lines = getTrimmedTextLinesArrayFromHTMLBlock($_POST['TAData']));
$whitelist = array("description");
foreach ($lines as $line)
{
    if (! $tags = get_meta_tags($line)) continue;
    echo '<tr>';
    foreach ($tags as $key => $meta)
    {
        if (! in_array($key, $whitelist)) continue;
        echo '<td>' . $meta . '</td>';
    }
    echo '</tr>';
}

I hope this is helpful.