> 地理
瑞文测试怎么换算(瑞文标准测试结果表怎样看)
在生活中,很多人可能想了解和弄清楚把瑞文测试的Excel的数据转换为代码,PHP代码实现的相关问题?那么关于瑞文测试怎么换算的答案我来给大家详细解答下。
客户需求是把Excel的分数和年龄对应的Excel数据展示在结果页面
解决思路分析:
纵坐标分数1-72, 横坐标年龄5.5-64
数据不具有连续性,写if、else判断要72x23个,有一些可以合并,大概还是100+个if else
换个思路,横竖就是二维数组,把excel的数据解析为二维数组即可,直接粘贴复制到记事本,用\n 换行分割为一层,用空格分割为二层数组
代码如下:
$str = &34;;$arr = explode(&34;,$str);$arr = array_filter($arr);$arr = array_values($arr);foreach($arr as &$val){ $arr2 = explode(&34;,$val); $arr2 = array_filter($arr2); $arr2 = array_values($arr2); $val = $arr2;}
第二步,因为横坐标是有区间的40-44都算一个key,单独要写一下这部分逻辑
if($age <= 5.5){ $age_key=0; }elseif($age <= 6.5){ $age_key=1; }elseif($age <= 7.5){ $age_key=2; }elseif($age <= 8.5){ $age_key=3; }elseif($age <= 9.5){ $age_key=4; }elseif($age <= 10.5){ $age_key=5; }elseif($age <= 11.5){ $age_key=6; }elseif($age <= 12.5){ $age_key=7; }elseif($age <= 13.5){ $age_key=8; }elseif($age <= 14.5){ $age_key=9; }elseif($age <= 15.5){ $age_key=10; }elseif($age <= 16.5){ $age_key=11; }elseif($age <= 17.5){ $age_key=12; }elseif($age <= 18.5){ $age_key=13; }elseif($age > 18.5 &&$age <= 24){ $age_key=14; }elseif($age >= 25 &&$age <= 29){ $age_key=15; }elseif($age >= 30 &&$age <= 34){ $age_key=16; }elseif($age >= 35 &&$age <= 39){ $age_key=17; }elseif($age >= 40 &&$age <= 44){ $age_key=18; }elseif($age >= 45 &&$age <= 49){ $age_key=19; }elseif($age >= 50 &&$age <= 54){ $age_key=20; }elseif($age >= 55 &&$age <= 59){ $age_key=21; }else{ //if($age >= 60 &&$age <= 64) $age_key=22; }
最后测试和检查一下,score是有可能大于72的,key越界,所以限制一下
$score > 72 ? $score=72:&34;;
最终版本
private function getZhishang($score,$age){ $str = &34;;$arr = explode(&34;,$str);$arr = array_filter($arr);$arr = array_values($arr);foreach($arr as &$val){ $arr2 = explode(&34;,$val); $arr2 = array_filter($arr2); $arr2 = array_values($arr2); $val = $arr2;} if($age <= 5.5){ $age_key=0; }elseif($age <= 6.5){ $age_key=1; }elseif($age <= 7.5){ $age_key=2; }elseif($age <= 8.5){ $age_key=3; }elseif($age <= 9.5){ $age_key=4; }elseif($age <= 10.5){ $age_key=5; }elseif($age <= 11.5){ $age_key=6; }elseif($age <= 12.5){ $age_key=7; }elseif($age <= 13.5){ $age_key=8; }elseif($age <= 14.5){ $age_key=9; }elseif($age <= 15.5){ $age_key=10; }elseif($age <= 16.5){ $age_key=11; }elseif($age <= 17.5){ $age_key=12; }elseif($age <= 18.5){ $age_key=13; }elseif($age > 18.5 &&$age <= 24){ $age_key=14; }elseif($age >= 25 &&$age <= 29){ $age_key=15; }elseif($age >= 30 &&$age <= 34){ $age_key=16; }elseif($age >= 35 &&$age <= 39){ $age_key=17; }elseif($age >= 40 &&$age <= 44){ $age_key=18; }elseif($age >= 45 &&$age <= 49){ $age_key=19; }elseif($age >= 50 &&$age <= 54){ $age_key=20; }elseif($age >= 55 &&$age <= 59){ $age_key=21; }else{ //if($age >= 60 &&$age <= 64) $age_key=22; } $score > 72 ? $score=72:&34;; return $arr[$score-1][$age_key]; }
最终运行结果
温馨提示:通过以上关于把瑞文测试的Excel的数据转换为代码,PHP代码实现内容介绍后,相信大家有新的了解,更希望可以对你有所帮助。