我有一个看起来像这样的链接http://site.com/numbers_and_letters/This_is_what-I-need_to-retrieve.html
我基本上需要检索这部分:This_is_what-I-need_to-retrieve
并且还用空格替换破折号和下划线,所以它最终看起来像这样:This is what I need to retrieve
我是正则表达式的新手,所以这就是我正在使用的:(它可以工作但性能很差)
function clean($url)
{
$cleaned = preg_replace("/http:\/\/site.com\/.+\//", '', $url);
$cleaned = preg_replace("/[-_]/", ' ', $cleaned);
//remove the html extension
$cleaned = substr($cleaned, 0,-4);
return $cleaned;
}