1 <?php 2 $arr = array( 3 ‘id1‘ => ‘1‘, 4 ‘id2‘ => ‘12‘, 5 ‘id3‘ => ‘13‘, 6 ‘id4‘ => ‘14‘, 7 ‘id5‘ => ‘15‘, 8 ‘id6‘ => ‘16‘, 9 ‘id7‘ => ‘17‘, 10 ‘id8‘ => ‘8‘, 11 ‘money1‘ => ‘1‘, 12 ‘backMoney1‘ => ‘1‘, 13 ‘money2‘ => ‘12‘, 14 ‘backMoney2‘ => ‘12‘, 15 ‘money3‘ => ‘13‘, 16 ‘backMoney3‘ => ‘13‘, 17 ‘money4‘ => ‘14‘, 18 ‘backMoney4‘ => ‘14‘, 19 ‘money5‘ => ‘15‘, 20 ‘backMoney5‘ => ‘15‘, 21 ‘money6‘ => ‘1‘, 22 ‘backMoney6‘ => ‘6‘, 23 ‘money7‘ => ‘‘, 24 ‘backMoney7‘ => ‘‘, 25 ‘money8‘ => ‘‘, 26 ‘backMoney8‘ => ‘‘ 27 ); 28 29 $arr_2 = array_splice($arr,8); //$arr_2 money,backmoney数组 【8】 30 $idArr = $arr; //idArr id号数组 31 32 for($i = 0;$i < 8; $i++){ //【8】 33 $reArr[$i] = array_merge(array_splice($arr_2,0,2), array_splice($idArr,0,1)); //$reArr 最终数组 【2】 34 } 35 36 37 for($i = 1,$j=0;$i <= 8,$j<8; $i++,$j++){ //【8】 38 $idKey = "id$i"; 39 $moneyKey = "money$i"; 40 $backMoneyKey = "backMoney$i"; 41 42 // var_dump($reArr[$j][$idKey]); //$arr数组中id1键名的值 43 // var_dump($reArr[$j][$moneyKey]); //$arr数组中money1键名的值 $where[‘amount‘] = $reArr[$j][$moneyKey] 44 // var_dump($reArr[$j][$backMoneyKey]); //$arr数组中backmoney1键名的值 $where[‘return_amount‘] = $reArr[$j][$backMoneyKey] 45 46 $where[‘?‘] = $reArr[$j][$moneyKey]; 47 $where[‘?‘] = $reArr[$j][$backMoneyKey]; 48 M(‘fanwe_?_?_?_?‘)->where(" id = ‘$reArr[$j][$idKey]‘ ")->save($where); 49 } 50 51 ?>
时间: 2024-10-10 21:46:56