Preg_match_all <a

后端 未结 6 1822
天命终不由人
天命终不由人 2020-12-02 02:25
6条回答
  •  鱼传尺愫
    2020-12-02 03:22

    This is my solution:

    ", $website, $matches); // save all links \x22 = "
    
    // delete redundant parts
    $matches = str_replace("a href=", "", $matches); // remove a href=
    $matches = str_replace("\"", "", $matches); // remove "
    
    // output all matches
    print_r($matches[1]);
    ?>
    

    I recommend to avoid using xml-based parsers, because you will not always know, whether the document/website has been well formed.

    Best regards

提交回复
热议问题