dongzhuo2010 2012-04-11 11:59
浏览 26
已采纳

使用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

  • 写回答

3条回答 默认 最新

  • dongxiatuo9827 2012-04-11 12:05
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器