Skip to content

Instantly share code, notes, and snippets.

@drewgates
Created July 25, 2016 02:52
Show Gist options
  • Save drewgates/52a9412f2b4b74b17f390955c65dee5a to your computer and use it in GitHub Desktop.
Save drewgates/52a9412f2b4b74b17f390955c65dee5a to your computer and use it in GitHub Desktop.
php script to split and rewrite a URL
<?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