0 ? 1 : 2); for ( $i = 0; $i < count( $inteiro ); $i++ ) { $valor = $inteiro[$i]; $rc = (($valor > 100) && ($valor < 200)) ? "cento" : $c[$valor[0]]; $rd = ($valor[1] < 2) ? "" : $d[$valor[1]]; $ru = ($valor > 0) ? (($valor[1] == 1) ? $d10[$valor[2]] : $u[$valor[2]]) : ""; $r = $rc . (($rc && ($rd || $ru)) ? " e " : "") . $rd . (($rd && $ru) ? " e " : "") . $ru; $t = count( $inteiro ) - 1 - $i; $r .= $r ? " " . ($valor > 1 ? $plural[$t] : $singular[$t]) : ""; if ( $valor == "000") $z++; elseif ( $z > 0 ) $z--; if ( ($t == 1) && ($z > 0) && ($inteiro[0] > 0) ) $r .= ( ($z > 1) ? " de " : "") . $plural[$t]; if ( $r ) $rt = $rt . ((($i > 0) && ($i <= $fim) && ($inteiro[0] > 0) && ($z < 1)) ? ( ($i < $fim) ? ", " : " e ") : " ") . $r; } $rt = mb_substr( $rt, 1 ); return($rt ? trim( $rt ) : "zero"); } private 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; } }