substr($matches[0], 0, 3) . '****' . substr($matches[0], -4), $text ); return is_string($masked) ? $masked : $text; } }