PHP way of parsing HTML string

前端 未结 3 1943
时光取名叫无心
时光取名叫无心 2021-01-18 08:28

I have a php string that contains the below HTML I am retrieving from an RSS feed. I am using simple pie and cant find any other way of splitting these two datasets it gets

3条回答
  •  执念已碎
    2021-01-18 09:18

    $received_str = 'Your received html';
    
    $html = str_get_html($received_str);
    
    //Image tag
    $img_tag = $html->find("img", 0)->outertext;
    
    //Example Text
    $example_text = $html->find('div[style=example]', 0)->last_child()->innertext;
    

    See Here: http://simplehtmldom.sourceforge.net/manual.htm

提交回复
热议问题