Home  >  Article  >  Backend Development  >  Use PHP questionnaire survey results statistics

Use PHP questionnaire survey results statistics

墨辰丷
墨辰丷Original
2018-06-07 10:14:262614browse

This article mainly introduces the statistics of questionnaire survey results using PHP. Interested friends can refer to it. I hope it will be helpful to everyone.

Background:

Due to specific work reasons, I made a paper questionnaire. The main content of the questionnaire is to ask users to answer their requirements ( Numbered A, B....) for priority sorting, so the results I got were hundreds of results similar to A>I>H>G>D.... and so on.

Goal:

Conduct a quantitative evaluation of this requirement based on the user's ranking results. The final result is expected to be A:, B:, C:.... ., to find out which elements are relatively important and others are relatively unimportant.

Method:

According to the ranking of the numbers, assign different weights, count all the results, and summarize these weights. For example: The result "ABCDEFGHIJ" means that item A gets points, item J gets points, and item D gets points.

Knowledge points:

File reading; looping; associative array; array sorting.

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);

Summary: The above is the entire content of this article, I hope it will be helpful to everyone's study.

Related recommendations:

How to get the operating system type in php

Use PHP's APC module to make upload progress Article

php method to filter all whitespace characters

The above is the detailed content of Use PHP questionnaire survey results statistics. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn