0

我想把我输出的 PHP 放到一个表中,但它不喜欢它......

我想要的布局是这样的

ROW - 描述 URL ROW2- 元描述

即使我输入多个 URL,它也需要保持相同的布局。

现在发生的情况是,当我输入大量网址时,它会将所有相同的部分放入同一个单元格中。我该如何更改?

抱歉很难解释...

这是代码:

<?php
ini_set( "display_errors", 0);
//make the array 
$TAarray = explode("\n", 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']))?"<tr><td>Description($line)</td>  </tr>".$tags['description']:"<tr><td>Description($line)</td></tr><tr><td>No Meta    Description</td></tr>.";
        echo '</tr>';
}

?>
4

2 回答 2

1

你有一些尴尬的 HTML 那里..尝试这样做:

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

        //start a new row in the table
        echo '<tr>';
        if(isset($tags['description'])){
            //add two cells to the table.
            echo "<td>Description($line)</td>";
            echo "<td>{$tags['description']}</td>";
        } else {
            echo "<td>Description($line)</td>"
            echo "<td>No Meta Description</td>";
        }
        echo '</tr>';
}
echo "</table>";
于 2012-04-11T12:55:40.143 回答
0
//make the array 
$data='http://stackoverflow.com 
 http://ebay.com/';
$TAarray = explode("\n", strip_tags($data)); 
echo "<table>";
foreach ($TAarray as $key => &$line) {
        $line = trim($line); 
        // get the meta data for each url
        $tags = get_meta_tags($line);

        echo '<tr>';
        if(isset($tags['description'])){

        echo "<tr><td>Description($line):".$tags['description']:" </td> "; else{

            "</tr><tr><td>Description($line)</td></tr><tr><td>No Meta    Description</td></tr>.";
        echo '</tr>';
        }
}
echo "</table>";
于 2012-04-11T12:59:45.453 回答