数组相加为什么取出了只有第一个值呢?麻烦各位给看一下。解决方法
程序员文章站
2024-02-14 20:36:52
...
数组相加为什么取出了只有第一个值呢?麻烦各位给看一下。
- PHP code
Array( [1] => 3 [2] => 3 [3] => 4 [4] => 4 [5] => 4 [6] => 3 [7] => 4 [8] => 4 [10] => 4 [11] => 4 [12] => 5 [13] => 4 [14] => 1 [16] => 3 [17] => 2 [18] => 3 [19] => 4 [22] => 1 [23] => 2 [24] => 4 [25] => 3 [26] => 3 [27] => 2 [28] => 3 [29] => 3 [30] => 4 [31] => 4 [32] => 4 [33] => 4 [34] => 5 [35] => 4 [36] => 3 [37] => 4 [38] => 4 [39] => 4 [40] => 3 [41] => 3 [42] => 3 [43] => 3 [44] => 2 [46] => 4 [49] => 4 [50] => 1 [51] => 1 [53] => 1 [55] => 3 [56] => 4 [57] => 4 [58] => 4 [59] => 4 [60] => 3 [61] => 3 [62] => 4 [63] => 5 [64] => 4 [65] => 1 [66] => 2 [67] => 3)
- PHP code
public function countOfconstitutionType ( $arrayOptionsId ) {$strFractionType = ""; $resultFraction = ""; if ( isset($arrayOptionsId) && is_array($arrayOptionsId) && !empty($arrayOptionsId) ) {$pingheFraction = "";foreach( $arrayOptionsId as $key=>$value ) {//echo "key:".$key."--".$value."
";print_r($arrayOptionsId);if ( $key == 17 || $key == 18 || $key == 19 || $key == 5 || $key == 13 || $key == 22 || $key == 23 ) { $yangxFraction += $value ; echo "111:".$yangxFraction."
";}if ( $key == 24 || $key == 25 || $key == 26 || $key == 27 || $key == 28 || $key == 29 || $key == 30 || $key == 31 ) { $yinxFraction += $value ;}if ( $key == 2 || $key == 10 || $key == 11 || $key == 12 || $key == 13 || $key == 14 || $key == 3 || $key == 16 ) { $qixFraction += $value ;}if ( $key == 32 || $key == 33 || $key == 34 || $key == 35 || $key == 36 || $key == 37 || $key == 38 || $key == 39 ) { $tansFraction += $value ;}if ( $key == 40 || $key == 41 || $key == 42 || $key == 43 || $key == 44 || $key == 45 || $key == 46 ) { $wenrFraction += $value ;}if ( $key == 47 || $key == 48 || $key == 49 || $key == 50 || $key == 51 || $key == 8 || $key == 53 ) { $xuyFraction += $value ;}if ( $key == 61 || $key == 62 || $key == 63 || $key == 64 || $key == 65 || $key == 66 || $key == 67 ) { $tedFraction += $value ;}if ( $key == 4 || $key == 55 || $key == 56 || $key == 57 || $key == 58 || $key == 59 || $key == 60 ) { $qiyFraction += $value ;}if ( $key == 1 || $key == 2 || $key == 3 || $key == 4 || $key == 5 || $key == 6 || $key == 7 || $key == 8 ) { if ( ( $key == 2 || $key == 3 || $key == 4 || $key == 5 || $key == 7 || $key == 8 ) && $value == 1 ) { $value = 5 ; } if ( ( $key == 2 || $key == 3 || $key == 4 || $key == 5 || $key == 7 || $key == 8 ) && $value == 2 ) { $value = 4 ; } if ( ( $key == 2 || $key == 3 || $key == 4 || $key == 5 || $key == 7 || $key == 8 ) && $value == 3 ) { $value = 3 ; } if ( ( $key == 2 || $key == 3 || $key == 4 || $key == 5 || $key == 7 || $key == 8 ) && $value == 4 ) { $value = 2 ; } if ( ( $key == 2 || $key == 3 || $key == 4 || $key == 5 || $key == 7 || $key == 8 ) && $value == 5 ) { $value = 1 ; } $pingheFraction += $value ;}$resultFraction = $yangxFraction."#".$yinxFraction."#".$qixFraction."#".$tansFraction."#".$wenrFraction."#".$xuyFraction."#".$tedFraction."#".$qiyFraction."#".$pingheFraction ;return $resultFraction;}}}相关文章
相关视频
下一篇: 集合框架 博客分类: java