Created
July 25, 2016 02:52
-
-
Save drewgates/52a9412f2b4b74b17f390955c65dee5a to your computer and use it in GitHub Desktop.
php script to split and rewrite a URL
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 | |
myURL = 'blogs/1/2/all-blogs'; | |
fragments = myURL.split('/'); | |
//don't need to touch fragments[0], because we want it to stay 'blogs' | |
fragments[1] = 3; | |
fragments[2] = 8; | |
fragments[3] = "whatever"; | |
newURL = fragments.join('/'); | |
//newURL is now set to '/blogs/3/8/whatever' | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment