Using Php to Hide Important Information

The title might be a little silly :) but in some web sites when we add our phone number we can see only first 2 digit and last 2 digit. Rest of the numbers are filtered as ****

Today i prepared a function because i needed in my project.

<?php

function privateStr($str, $start, $end){
   $after = mb_substr($str, 0, $start, 'utf8');
   $repeat = str_repeat('*', $end);
   $before = mb_substr($str, ($start + $end), strlen($str), 'utf8');
   return $after.$repeat.$before;
}

Usage is like this ;

<?php

$number = '09856584785';
echo privateStr($number , 3, 5); // Result: 098*****785

 In this way, showing the just only one part of private parts you hide the important information parts from others.

Comments

There are no comments, make the firs comment