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
1. Combine RIGHT and LEN to Remove the First Character from the Value. Using a combination of RIGHT and LEN is the most suitable way to remove the first character from a cell or from a text string. This formula simply skips the first character from the text provided and returns the rest of the characters.
trim( $str, "/" );
is probably your best/fastest bet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With