eg. via preg_replace ()
$testdata = array(
'http://stackoverflow.com/questions/1899537/ab',
'http://stackoverflow.com/questions/1899537/abc',
'http://stackoverflow.com/questions/1899537/abcd',
'http://stackoverflow.com/questions/1899537/ajaxify-multipart-encoded-form-upload-forms'
);
foreach ($testdata as $in ) {
$out = preg_replace('/(?<=^.{22}).{4,}(?=.{20}$)/', '...', $in);
echo $out, "\n";
}
prints
http:
http:
http:
http:
source
share