Guys,
Good morning.

I'm bringing you another useful function in everyday life, which removes number formatting, causing “R$ 1,487,257.55” to become a string with the format of a float, that is, “1487257.55”.

For this, I created the class clsText and the function removeFormatacaoNumero:

<?php
class clsTexto 
{
    public static function removerFormatacaoNumero( $strNumero )
    {

        $strNumero = trim( str_replace( "R$", null, $strNumero ) );

        $vetVirgula = explode( ",", $strNumero );
        if ( count( $vetVirgula ) == 1 )
        {
            $acentos = array(".");
            $resultado = str_replace( $acentos, "", $strNumero );
            return $resultado;
        }
        else if ( count( $vetVirgula ) != 2 )
        {
            return $strNumero;
        }

        $strNumero = $vetVirgula[0];
        $strDecimal = mb_substr( $vetVirgula[1], 0, 2 );

        $acentos = array(".");
        $resultado = str_replace( $acentos, "", $strNumero );
        $resultado = $resultado . "." . $strDecimal;

        return $resultado;

    }
}
?>

To use the function is very simple:

//Carregamos a nossa classe para a memória
require_once("classes/clsTexto.php");

//Chamamos a função criada
echo clsTexto::removerFormatacaoNumero("R$ 1.487.257,55"); //Vai exibir na tela 1487257.55

Simple, right?