PHP/regex: How to get the string value of HTML tag?

前端 未结 8 2116
忘了有多久
忘了有多久 2020-11-28 07:24

I need help on regex or preg_match because I am not that experienced yet with regards to those so here is my problem.

I need to get the value \"get me\" but I think

8条回答
  •  再見小時候
    2020-11-28 07:55

    $userinput = "http://www.example.vn/";
    //$url = urlencode($userinput);
    $input = @file_get_contents($userinput) or die("Could not access file: $userinput");
    $regexp = "]*>(.*)<\/tagname>";
    //==Example:
    //$regexp = "]*>(.*)<\/div>";
    
    if(preg_match_all("/$regexp/siU", $input, $matches, PREG_SET_ORDER)) {
        foreach($matches as $match) {
            // $match[2] = link address 
            // $match[3] = link text
        }
    }
    

提交回复
热议问题