Replacing the first few digits with #

I want to hide the first 6 digits of social security. I have them as 123-456-7890

I want to show ### - ### - 7890

how can i do it thanks

0
source share
2 answers
$ssn = '123-456-7890';    
$ssn = '###-###-'.substr ($ssn , 8);
+8
source

You can use the substr method to get the rightmost 4 characters from the SSN using a negative length:

$ssn = '111-222-4567';
$ssn_obscured = '###-###-' . substr($ssn, -4);

For more information on the method, see http://us.php.net/substr .

+2
source

Source: https://habr.com/ru/post/1753425/


All Articles