dqy0707 2012-04-11 08:49
浏览 25
已采纳

PHP数组仅使用“获取元标记”功能的第一行文本区域

I am fairly new to PHP so please bear with me :)

What I am trying to do if place URL's into a text area, then pull in the meta data for each.

I have made the script, but when I place more then one URL into the text area it only returns data for the last URL entered, I thought maybe you guys can help me :)

<form method="POST">
<textarea name="TAData">
</textarea>
<input type="submit" value="submit"/>
</form>

<div id="checkboxes">
<input type="checkbox" name="vehicle" value="PR" /> Show me the PR<br />
<input type="checkbox" name="vehicle" value="KW Tag" /> Show me the KW tag<br />
<input type="checkbox" name="vehicle" value="Title Tag" /> Show me the Title tag<br />
</div>
<div id="checkboxes">
<input type="checkbox" name="vehicle" value="1stH1" /> Show me the 1st H1<br />
<input type="checkbox" name="vehicle" value="2ndH1" /> Show me the 2nd H1 tag<br />
<input type="checkbox" name="vehicle" value="SeedKW" /> Show me Seed KW's<br />
</div>

<div id="nofloat"></div>

<?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);

unset($tags["content-type"]);
unset($tags["page-type"]);
unset($tags["page-topic"]);
unset($tags["audience"]);
unset($tags["content-language"]);       

            echo '<tr>';
            foreach ($tags as $meta)        
            {
                    echo '<td>' . $meta . '</td>';
            }
            echo '</tr>';

?>
  • 写回答

2条回答 默认 最新

  • douzong6649 2012-04-11 08:54
    关注

    The closing } after where you use trim on the line means that the foreach ends and only the last line is available after the loop for the other operations. Just move that bracket to the end.

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

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测