dongmangzong8006 2017-04-23 16:43
浏览 66
已采纳

如何在HTML标记中获取图像URL?

I need to get proper image for each article. Every single image is saved among different HTML tags in different rows in database. So how should I get img URL with PHP code?

 <p><img src="images/akhbar/5/q103.jpg" alt="q103" style="display: block; margin-left: auto; margin-right: auto;" height="315" width="675" /></p>
<p> Who is Sara Bareilles on Sing Off</p>

image urls are saved in introtext row in my database

  • 写回答

2条回答 默认 最新

  • dtrb96410 2017-05-09 09:13
    关注

    thanks for your answers.i could solve my problem with this code.hope help other guys.

    $text = $row["your html text from database row"]; 
    preg_match('/< *img[^>]*src *= *["\']?([^"\']*)/i', $text, $img);
                $pics=$img[1];  
    

    output is ($pics)= ( images/akhbar/5/q103.jpg )

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

报告相同问题?

悬赏问题

  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办