: This article mainly introduces php statistics on the questionnaire results. For more information about PHP tutorials, see. Background:
For specific work, I made A paper questionnaire. The main content of the questionnaire is to allow users to have 10 requirements (numbered A, B ....) so the result I get is several hundred copies, similar to A> I> H> G> D .....
Objectives:
These 10 requirements are quantified based on the user's sorting results. The final result is A: 78, B: 68, C: 70 ....., to find out which element is relatively important, while others are relatively unimportant.
Practice:
Based on the ranking of numbers, assign different weights, calculate all results, and summarize these weights. For example, the result of "ABCDEFGHIJ" indicates that A scored 10 points, J scored 1 point, and D scored 7 points.
Knowledge Point:
File reading;Loop; Joined array; array sorting.
Php code:
1 $ rs = array ("A" => 0, "B" => 0, "C" => 0, "D" => 0, "E" => 0, "F" => 0, "G" => 0, "H" => 0, "I" => 0, "J" => 0); 2 $ handle = fopen ('. /file.txt ', 'r'); 3 while (! Feof ($ handle) 4 {5 $ string = fgets ($ handle, 1024); 6for ($ I = 0; $ I
Note: file.txt is a text file with each row representing the result of a questionnaire, similar to "ABCDEFGHIJ. How can this file be obtained? Okay, I admit that I did not manually enter the questionnaire. I have asked some help (why not do the online questionnaire? Saves the trouble)
The above section describes the php statistics on the questionnaire results, including the Loop content, and hopes to help those who are interested in the PHP Tutorial.