php 问卷调查结果统计,php问卷调查统计_PHP教程

WBOY
Release: 2016-07-12 09:07:54
Original
828 people have browsed it

php 问卷调查结果统计,php问卷调查统计

背景:

     由于具体工作的原因,我做了一份纸质的问卷调查表,调查表的主要内容是让用户对项要求(编号为A,B....)进行优先级排序,所以我得到的结果是好几百份类似于A>I>H>G>D....等结果。

目标:

     根据用户的排序结果对这项要求进行量化考评,最终的结果希望是A:,B:,C:.....,以找出哪一个要素相对重要,而另一些相对不重要。

做法:

     根据编号的排位名次,赋与不一样的权重,统计所有的结果,将这些权重汇总。例如:“ABCDEFGHIJ”这个结果表示A这一项得到分,J这项得到了分,D这项得到了分。

知识点:

     文件读取;循环;关联数组;数组排序。

php代码:

 $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);
Copy after login

说明:file.txt是一个文本文件,其中的每一行表示一份问卷的结果,类似于“ABCDEFGHIJ”这样的东西。这个文件是如何得到了呢?好吧,我承认不是我自己手动录入的,我找了些人帮忙(为什么不做网上问卷呢?省得这么麻烦)

以上内容就是本文给大家介绍的php 问卷调查结果统计,希望对大家有所帮助。

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1058149.htmlTechArticlephp 问卷调查结果统计,php问卷调查统计 背景: 由于具体工作的原因,我做了一份纸质的问卷调查表,调查表的主要内容是让用户对项要求...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!