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 .
source
share