给出:
rescue
或
$URL = "https://somedomain.com/these-are-words/";
我如何获得?:
$URL = "http://somedomain.com/these-are-words/";
答案 0 :(得分:1)
$url = "https://somedomain.com/these-are-words/";
$path=parse_url($url, PHP_URL_PATH); //extract the path
$words=str_replace('-',' ',trim($path,'/')); //replace the hyphen with spaces and remove the /'s
echo $words; //these are words
答案 1 :(得分:0)
答案 2 :(得分:0)
可以尝试类似(?:/[^/]+)+/?$