Background:
Because of the specific work, I made a paper questionnaire, the main content of the questionnaire is to allow users to the item requirements (numbered A,b ...). To prioritize, so I get hundreds of copies of the results that are similar to a>i>h>g>d .... and other results.
Goal:
According to the user's ranking results of the quantitative evaluation of this requirement, the final result of the hope is a:,b:,c: ... to find out which element is relatively important, while others are relatively unimportant.
Practice:
According to the number of ranking ranking, assign a different weight, statistics all the results, the weights are summarized. For example, the result of "Abcdefghij" indicates that the term "a" is divided, that the J is divided and that D is divided.
Knowledge Points:
file read; loop; associative array; array sort.
PHP Code:
$rs =array ("A" =>, "B" =>, "C" =>, "D" =>, "E" =>, "F" =>, "G" =>, "H" =>, "I" =>, "J" =>);
$handle = fopen ('./file.txt ', ' R ');
while (!feof ($handle))
{
$string = fgets ($handle,);
for ($i =; $i <strlen ($string); $i + +)
{
$t = Strtoupper ($string [$i]);
if (Isset ($rs [$t]))
$rs [$t] = $rs [$t]+ strlen ($string)-$i;
}
}
Fclose ($handle);
Arsort ($RS);
Var_dump ($RS);
Description: File.txt is a text file in which each line represents the result of a questionnaire, similar to something like "Abcdefghij". How did this file get? OK, I admit I did not manually input, I found some help (why not do online questionnaires?) Save this trouble)
The above content is this article to everybody introduced the PHP Questionnaire survey result Statistics, hoped has the help to everybody.