How to remove the first & last slash from a url if it's exists?
Posted
by David
on Stack Overflow
See other posts from Stack Overflow
or by David
Published on 2010-06-01T18:00:31Z
Indexed on
2010/06/01
18:03 UTC
Read the original article
Hit count: 258
Hi I use parse_url() to get the path of a url but i want to remove the first slash & the last if it's exists.
Example:
"/posts/funny-dog/" -> "posts/funny-dog"
"/" -> "" // Because http://www.google.com/ path is a slash
"/categories/politic" -> "categories/politics"
Thanks
© Stack Overflow or respective owner