I am trying to return html from a url that has two sections which need to have wildcards. I am pretty sure regex is the way to go (unless there are alternatives I am not aware of?)... but I can't seem to get it right. I don't have any knowledge of regex and was hoping someone could please help me with this.
The wildcards need to support any number of alphanumeric characters, including underscores and as many special characters as possible.
All of these are possible scenarios:
https://www.example.com/type/1062483_name
https://www.example.com/type/name_ii
https://www.example.com/type/name
I've tried using all the regex tools online but I can't seem to be able to match it. Here is what my code looks like at the moment:
$url = $baseurl . $type . $wildcard1 . $name . $wildcard2
function get_http_response_code($url) {
$headers = get_headers($url);
return substr($headers[0], 9, 3);
}
if(get_http_response_code($url) == "200"){
$html = file_get_contents($url);
}
I need (get_http_response_code($url) == "200")
to return true.
Any advice on how to make this work would be amazing. Thanks!