dtnpzghys01643322 2009-11-07 01:07
浏览 5
已采纳

如何从字符串中删除第一个链接?

How to remove first link with image from this text with PHP?

<a href="some link"><img src="image link" /></a>Lorem ipsum dolor sit amet, consectetur adipiscing elit.** 
  • 写回答

3条回答 默认 最新

  • doutan3192 2009-11-07 01:12
    关注

    I would start by splitting the line by the '>' character..

    PHP:

    $line = "<a href=''><img src=''></a>blah blah blah";
    $parts = explode('>', $line);
    

    If you wanted the image....

    $img = $parts[1].">";
    

    If you want just the text...

    $text = $parts[3];
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?