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条)

报告相同问题?

悬赏问题

  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了