How to match a part of an <iframe> tag?

后端 未结 6 2020
小鲜肉
小鲜肉 2021-01-21 13:48

I\'m trying to match the highlighted parts of this string:

 maybe something here src=\"http://some.random.url.com/\" and the string continues.         


        
6条回答
  •  执笔经年
    2021-01-21 13:52

    You should use a DOM parser for that. Here's an example with DOMDocument :

    loadHTML(file_get_contents('yourFileNameHere.html'));
        $lst = $document->getElementsByTagName('iframe');
    
        for ($i=0; $i<$lst->length; $i++) {
            $iframe= $lst->item($i);
            echo $iframe->attributes->getNamedItem('src')->value, '
    '; } ?>

提交回复
热议问题