Skip to content

Instantly share code, notes, and snippets.

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