Re: Re: Anagram Type Puzzle

From: Date: Mon, 10 Sep 2001 09:36:49 +0000
Subject: Re: Re: Anagram Type Puzzle
Groups: php.general 
Request: Send a blank email to php-general+get-66711@lists.php.net to get a copy of this message
<html> <body> <?php $tab=array("a"=>26,"b"=>25,"c"=>24,"d"=>23, "e"=>22,"f"=>21,"g"=>20,"h"=>19, "i"=>18,"j"=>17,"k"=>16,"l"=>15, "m"=>14,"n"=>13,"o"=>12,"p"=>11, "q"=>10,"r"=>9,"s"=>8,"t"=>7, "u"=>6,"v"=>5,"w"=>4,"x"=>3, "y"=>2,"z"=>1); $fid=fopen("testfile.txt","r"); $line_num=0; while (!feof($fid)) { $line_num++; file://echo "ligne : $line_num\n<br>\n"; $line = strtolower(fgets($fid,4096)); file://echo "contenu de la ligne : $line\n<br>\n"; $words= explode(" ",$line); while (list($foo,$word)=each($words)) { $word_value=0; for ($car=0;$car<strlen($word);$car++) { file://echo "lettre : $word[$car] - \t"; if ($letter_value=$tab[$word[$car]]) $word_value+=$letter_value; } file://echo "mot : $word; "; file://echo "valeur : $word_value\n<br>\n"; if ($word_value==100) echo "the word <b>$word</b> on line $line_value of the input file has a value of $word_value.<br>\n"; } } echo "<br>\n<font color=\"red\">If nothing appears above, no word with a value of 100 was found !!!\n"; ?> </body> </html> (°- Nayco, //\ Nayco@netcourrier.com v_/_ http://nayco.free.fr

« previous php.general (#66711) next »