I\'m doing some url rewriting in PHP and need to find URLS with a slash at the end and then do a 301 redirect. I thought there\'d be a simple PHP function to find last stri
You can use substr:
substr($str, -1)
This returns the last byte/character in a single-byte string. See also the multi-byte string variant mb_substr.
But if you just want to remove any trailing slashes, rtrim is probably the best solution.
And since you’re working with URLs, you might also take a look at parse_url to parse URLs as a trailing slash does not need to be part of the URL path.