background:
Because of the specific work, I made a paper questionnaire, the main content of the questionnaire is to allow users to request the item (number A, A, b ...). ) to prioritize, so I get a good hundreds of copies similar to A>i>h>g>d .... and other results.
Goal:
Based on the user's sequencing results to quantify this requirement, the final result would be a:,b:,c: ... to find out which one is relatively important, while others are relatively unimportant.
Practice:
According to the number of ranked position, to assign a different weight, statistics all the results, the weights are summarized. For example, the result of "Abcdefghij" indicates that a is a sub-item, j is a sub-item, and 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
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 out? Well, I admit that I did not manually input it, I found some people to help (why not do online questionnaires?) Save the trouble)
Above is the article to introduce the PHP Questionnaire survey results Statistics, I hope to be helpful to everyone.