Php statistics on the questionnaire results

Source: Internet
Author: User
: 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.