-1
When three numbers are typed the program displays the full name correctly, but when 2 or 1 number is typed it displays in the wrong order, example: I typed 51, it returns:
Unidade = 
Dezena = 1
Centena = 5
Unidade = 
Dezena = Décimo
Centena = Quingentésimo 
that is, I wanted him to take only the ten plus the unit, in the case of the example: Fifty-first
Follows the code:
<!DOCTYPE html>
<html>
<head>
    <title>Portfolio</title>
</head>
<body>
    <form method="post" action="outro.php">
        Numero: <input type="text" name="numero">
        <br>
        <input type="submit" name="Exibir">
    </form>
</body>
</html>
<?php
    // receber o número digitado
    $num = $_POST["numero"];
    echo "Número digitado: $num<br>";
    /*if ($num > 1000) {
        echo "Digite um número até mil";
        return false;
    } 
    if ($num === 1000) {
        echo "Milésimo";
    }*/
    $unidade = substr($num,2,1); // criar um array(vetor) pra cada unidade
    $dezena  = substr($num,1,1);
    $centena = substr($num,0,1);
    echo "<br>Unidade = $unidade";
    echo "<br>Dezena  = $dezena";
    echo "<br>Centena = $centena";
    // Vetor de Unidade
    $aUnidade[0] = "Zero";
    $aUnidade[1] = "Primeiro";
    $aUnidade[2] = "Segundo";
    $aUnidade[3] = "Terceiro";
    $aUnidade[4] = "Quarto";
    $aUnidade[5] = "Quinto";
    $aUnidade[6] = "Sexto";
    $aUnidade[7] = "Sétimo";
    $aUnidade[8] = "Oitavo";
    $aUnidade[9] = "Nono";
    // Vetor de Dezena
    $aDezena[0] = "";
    $aDezena[1] = "Décimo";
    $aDezena[2] = "Vigésimo";
    $aDezena[3] = "Trigésimo";
    $aDezena[4] = "Quadragésimo";
    $aDezena[5] = "Quinquagésimo";
    $aDezena[6] = "Sexagésimo";
    $aDezena[7] = "Septuagésimo ";
    $aDezena[8] = "Octogésimo ";
    $aDezena[9] = "Nonagésimo";
    // Vetor de Centena
    $aCentena[0] = "";
    $aCentena[1] = "Centésimo";
    $aCentena[2] = "Ducentésimo ";
    $aCentena[3] = "Tricentésimo ";
    $aCentena[4] = "Quadringentésimo ";
    $aCentena[5] = "Quingentésimo ";
    $aCentena[6] = "Sexcentésimo ";
    $aCentena[7] = "Septingentésimo ";
    $aCentena[8] = "Octingentésimo ";
    $aCentena[9] = "Nongentésimo ";
    echo "<br><br>";
    echo "Unidade = $aUnidade[$unidade]<br>";
    echo "Dezena  = $aDezena[$dezena]<br>";
    echo "Centena = $aCentena[$centena]<br>";
    echo "<br>";
    if (strlen($num) == 3) {
        echo "$aCentena[$centena] $aDezena[$dezena] $aUnidade[$unidade]";
    } elseif (strlen($num) == 2) {
        echo "$aDezena[$dezena] $aUnidade[$unidade]";
    } elseif (strlen($num) == 1) {
        echo "$aDezena[$dezena]";
    }
?>
I think you’ll have to improve this algorithm well, the generation of the extender is much more complicated than that.
– Maniero
Because it’s expensive, I noticed this by looking at forums, the code to generate the extensive is much more complex, the problem is that it is quite complicated for a beginner
– Leonardo Oliveira
Related: How to turn numeric digits into numbers in full? and How to generate a full value in Portuguese in MS Office Excel?
– rray
With class
NumberFormatterofintlit is possible to do this in English: https://ideone.com/ZzuSVW. Perhaps with the installation of some additional file it is also possible in Portuguese.– Woss