$path = '/home/to//my///site';
I am trying to remove unnecessary forward slashes /
from the path above
I am trying to get this results
/home/to/my/site
I've failed with str_replace
, since i don't know the number of slashes.
if someone wants to remove extra slashes from URL without removing first two slashes after http/https:
$url = preg_replace('/([^:])(\/{2,})/', '$1/', $url);
(thanks to ツ Liverbool how to remove multiple slashes in URI with 'PREG' or 'HTACCESS')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With