-1
I am a beginner in PHP and need to create a function that rewrites the text masking the CPF.
I, John Doe, Number 123.234.345/56, married to Beltrana, CPF 234.345.456/67, would like to request the registration of the property purchased Sicrano, CPF 345.456.567/78.
Turn
I, John Doe, CPF xxx, married to Beltrana, CPF xxx, would like to request the registration of the property purchased from Sicrano, CPF xxx.
I created the following function:
<?php
$texto = "Eu, Fulano, CPF 123.234.345/56,
casado com Beltrana, CPF 234.345.456/67,
gostaria de solicitar o registro do imóvel adquirido
de Sicrano, CPF 345.456.567/78.";
function reescreverCpfs($texto)
{
return preg_replace('/[^@\s]*.[^@\s]*\.[^@\s]*/',
'xxx',
$texto);
}
echo reescreverCpfs($texto);
But she’s printing the following:
I, John Doe, xxx married to Beltrana, xxx would like to request the registration of the property purchased of Sicrano, xxx
Could you help me?