Created
January 5, 2015 06:57
-
-
Save joerx/7dcbab3b1573a9445ba9 to your computer and use it in GitHub Desktop.
PHP: One-liner to strip leading and trailing slashes
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 | |
echo preg_replace('@^/|/$@', '', '/foo/'); // 'foo' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment