Created
December 19, 2014 04:22
-
-
Save joerx/bce177f4087d30c0efcc to your computer and use it in GitHub Desktop.
Strip leading/trailing slashes from a path-like string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Replace '#' with whatever substitute desired, use '' to strip | |
echo preg_replace('@^/|/$@', '#', '/foo/'); // #foo# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment