Example below replaces username and password with stars and leaves other parts intact.


Function


function obscureUriDetails($url)
{
return preg_replace('@(ftp|http)://.*:.*\@@', '$1://****:****@', $url);
}

Example


echo obscureUriDetails('http://username-goes-here:password-goes-here@drop.html/part/file.csv');
// http://*******:*******@drop.html/part/file.csv

echo obscureUriDetails('ftp://username-goes-here:password-goes-here@drop.html/part/file.csv');
// fpt://*******:*******@drop.html/part/file.csv