I have a PHP function which is supposed to remove a value with its starting / and ending / from a given URL.
for example: remove /page_###/ from http://my-domain.com/search/page_2/order_asc.
the result will be: http://my-domain.com/search/order_asc.
but also the URL may be like this: http://my-domain.com/search/order_asc/page_2. there is no ending / in the end;
function stripDir($url, $mask){
return preg_replace('/' . $mask . '[\s\S]+?/', '', $url);
}
the above function should be able to remove page_5 from following URLS...
stripDir('http://my-domain.com/search/page_5/order_asc', 'page') and stripDir('http://my-domain.com/search/order_asc/page_5', 'page')