I have the following URLs
http:
http:
http:
and so on...
using preg regex, how to remove the file name on the right? I guess this should match the first dash starting on the right, how can I do this?
So for example, if I run something like
$newUrl = preg_match('xxxxxx', '', $url);
or using
$newURL = preg_replace(...);
The variable $ newUrl will contain
http://domain.com/baby/smile/love/
keeping the trailing slash at the end. I was able to do this using the functions explode (), array_pop (), then implode () to get it back, just wondering if it is possible to use only regular expression.
Thanks.
source
share