On Mon, 10 Sep 2001 01:25:36 -0700, you wrote:

>So let's say the word 'acronym'
>
>A  + C  + R + 0  + N  + Y + M
>26 + 24 + 9 + 12 + 13 + 2 + 14  = 100
>
>My thoughts were to download a list of words in the dictionary, then read
>the file and somehow replace each letter by its number, then add each letter
>for each word and see which words would equal to 100.
>
>So I am emailing this list for any suggestions or examples of code that I
>can use to accomplish this. Any help?

function total ($word) {
        $total = 0;
        $word = strtoupper($word);
        for ($i=0; $i<strlen($word); $i++) {
                $total+=26-(ord($word[$i])-65);
        }
        return($total);
}

echo total('acronym');

djo


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to