Skip to content

Instantly share code, notes, and snippets.

@krmgns
Last active August 29, 2015 14:13
Show Gist options
  • Save krmgns/931195ebfd57e06a3d7e to your computer and use it in GitHub Desktop.
Save krmgns/931195ebfd57e06a3d7e to your computer and use it in GitHub Desktop.
Reduce duplicated slashes.
<?php
$url = "https://foo.com//bar/////ii?a=1";
$url = preg_replace("~(?<!:)/+~", "/", $url);
print($url); # https://foo.com/bar/ii?a=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment