PHP String Manipulation: Extract hrefs

后端 未结 4 1905
臣服心动
臣服心动 2020-11-29 13:22

I have a string of HTML that I would like to check to see if there are any links inside of it and, if so, extract them and put them in an array. I can do this in jQuery with

4条回答
  •  情深已故
    2020-11-29 13:56

    One line solution

    $href = (string)( new SimpleXMLElement($your_html_tag))['href'];
    

提交回复
热议问题