欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

php怎么循环读出多个id的内容

程序员文章站 2022-04-20 14:13:10
...
php如何循环读出多个id的内容
我的问题是URL传出多个ID比如:ABC.php?id=12345,34567,67890
关于多个ID数组去采集这些ID内容然后在一个页面显示该怎么写啊

最后效果应该是:
  • 12345.采集的第一个ID标题

  • 34567.采集的第二个ID标题

  • 67890.采集的第三个ID标题



  • 下面就是想修改的内容,希望高手帮忙,谢谢


    $urls="http://www.****.com/".$id.".htm";
    $content =get_url_content($urls);
    $title = get_word($content,'','');<br>?><br><li>=$id?>.=$title?></li> <br><font color="#FF8000">------解决方案--------------------</font><br><pre class="brush: php">$ids=explode(',',$_GET['id']);<br>foreach($ids as $id){<br> $urls="http://www.****.com/".$id.".htm";<br> $content =get_url_content($urls);<br> $title = get_word($content,'<title>','');<br><br> echo "<li>".$id.".".$title."</li>";<br>}
    ------解决方案--------------------
    $ids = $_GET;
    $idsArray = explode(',' , $ids);
    $titleArray;
    foreach($idsArray as $key=>$idItem)
    {
    $url = "http://www.****.com/".$idItem.".htm";
    $content = file_get_contents($url);
    $titleArray[] = get_word($content,'','');<br>}<br>foreach($titleArray as $key=>$titleItem)<br>{<br>echo "<li>$titleItem</li>";<br>}<br>不知道是否符合你的要求<div class="clear"> <a href="/default/index/url?u=aHR0cHM6Ly93d3cucGhwLmNuL2suaHRtbD90PTI=" target="_blank" rel="nofollow"><img onerror="this.src='/statics/superweb999/images/image_error.jpg'"src="/default/index/img?u=aHR0cHM6Ly9pbWcucGhwLmNuL3VwbG9hZC9jb3Vyc2UvMDAwLzAwMC8wNzEvNjIwYzYwNGY3NTI1MTk5NS5wbmc=" style="margin-top: 30px;" alt="php怎么循环读出多个id的内容" title="php怎么循环读出多个id的内容"></a><p style="float:right;font-size:13px;color:#999;"><span class="red">声明:</span>本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。</p> </div> <p class="article-relative-header">相关文章</p> <p class="article-relative-header">相关视频</p> <hr class="layui-clear"> <ul class="article-relative-ul"> <li> <span class="layui-badge-dots"></span><a class="relevant" href="/default/index/url?u=aHR0cHM6Ly93d3cucGhwLmNuL3BocC13ZWl6aWppYW9jaGVuZy00ODg4ODkuaHRtbA==" target="_blank" rel="nofollow">详解win10下PHP的安装配置(以php5.6为...</a> </li> <li> <span class="layui-badge-dots"></span><a class="relevant" href="/default/index/url?u=aHR0cHM6Ly93d3cucGhwLmNuL3BocC13ZWl6aWppYW9jaGVuZy00ODg4MzUuaHRtbA==" target="_blank" rel="nofollow">php Swoole实现毫秒定时计划任务(详解)</a> </li> <li> <span class="layui-badge-dots"></span><a class="relevant" href="/default/index/url?u=aHR0cHM6Ly93d3cucGhwLmNuL3BocC13ZWl6aWppYW9jaGVuZy00ODg4OTAuaHRtbA==" target="_blank" rel="nofollow">一文详解Windows和Linux环境下怎么安装配...</a> </li> <li> <span class="layui-badge-dots"></span><a class="relevant" href="/default/index/url?u=aHR0cHM6Ly93d3cucGhwLmNuL3BocC13ZWl6aWppYW9jaGVuZy00ODg4NTQuaHRtbA==" target="_blank" rel="nofollow">【DTM】PHP协程客户端v0.1 beta版本发...</a> </li> <li> <span class="layui-badge-dots"></span><a class="relevant" href="/default/index/url?u=aHR0cHM6Ly93d3cucGhwLmNuL3BocC13ZWl6aWppYW9jaGVuZy0xOTg0OTIuaHRtbA==" target="_blank" rel="nofollow">php怎么循环读出多个id的内容</a> </li> </ul> <ul class="article-relative-ul"> <li> <span class="layui-badge-dots"></span><a class="relevant" href="/default/index/url?u=aHR0cHM6Ly93d3cucGhwLmNuL2NvZGUvMTM4OTcuaHRtbA==" target="_blank" title="id,class,title,style标签四大通用属性" rel="nofollow">id,class,title,style标签四大通用属性</a> </li> <li> <span class="layui-badge-dots"></span><a class="relevant" href="/default/index/url?u=aHR0cHM6Ly93d3cucGhwLmNuL2NvZGUvMTc0MzQuaHRtbA==" target="_blank" title="前端开发基础视频-head标签和页面编码title标签使用" rel="nofollow">前端开发基础视频-head标签和页面编码title标签使用</a> </li> <li> <span class="layui-badge-dots"></span><a class="relevant" href="/default/index/url?u=aHR0cHM6Ly93d3cucGhwLmNuL2NvZGUvMTc0NDEuaHRtbA==" target="_blank" title="前端开发基础视频-图片标签img的使用和title的seo优化" rel="nofollow">前端开发基础视频-图片标签img的使用和title的seo优化</a> </li> <li> <span class="layui-badge-dots"></span><a class="relevant" href="/default/index/url?u=aHR0cHM6Ly93d3cucGhwLmNuL2NvZGUvMjQ1MzYuaHRtbA==" target="_blank" title="页面标题元素title" rel="nofollow">页面标题元素title</a> </li> <li> <span class="layui-badge-dots"></span><a class="relevant" href="/default/index/url?u=aHR0cHM6Ly93d3cucGhwLmNuL2NvZGUvMjU0MTkuaHRtbA==" target="_blank" title="new-title模块化制作" rel="nofollow">new-title模块化制作</a> </li> </ul>