I have links that vary and look something like this: somesite/articles/25/news/15/1/141720.html somesite/articles/10/25/updates/3/1/1413410.html somesite/makers/16/11/press/1/7/145623.html etc. etc. I need to strip / preg_replace everything except these (the html IDs at the end of the links): 141720.html 1413410.html 145623.html etc. etc. They always vary too. So... Is there a way? I was thinking stripping everything before the last slash forward, but then what? How do you get those html IDs? Thank you for any help.
I don't like regular expressions so I tend to use explode and then just get the last array element - efficient and readable. But there is a way to regex results into an array and select the last item too.
You may use string functions basename() and str_replace to do that you might use basename function to get end part of url and than use str_replace to remove it.