background:
Due to specific work reasons, I made a paper questionnaire. The main content of the questionnaire is to ask users to prioritize item requirements (numbered as A, B...). So the results I got were hundreds of results similar to A>I>H>G>D...... etc.
Target:
This requirement is quantitatively evaluated based on the user's sorting results. The final result is hoped to be A:, B:, C:... to find out which element is relatively important, while others are relatively unimportant.
practice:
According to the numbered ranking, assign different weights, count all the results, and summarize these weights. For example: The result of "ABCDEFGHIJ" means that the item A gets points, the item J gets points, and the 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('./', '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);
Description: is a text file, each line of which represents the result of a questionnaire, similar to something like "ABCDEFGHIJ". How did I get this file? OK, I admit that I didn’t enter it manually myself, so I asked some people to help (why not do online questionnaires? Save so much trouble)
The above content is the statistics of the php questionnaire survey results introduced to you in this article. I hope it will be helpful to you.