3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Your code here! // グルーピングキー1 $group1 = 'knrno'; // グルーピングキー2 $group2 = 'taxcd'; // 足す金額 $kin = 'gokin'; $parm = [ '0' => [ 'knrno' => '0001004_20181210__0_100_20190101', 'hancd' => '0001004', 'hannm' => '水戸上中妻', 'ssmdt' => '20181210', 'sekno' => '000382633', 'seiux' => 0, 'hanpos' => 311-4143, 'hanaddr1' => '水戸市大塚町1261-3', 'hanaddr2' => '', 'hanaddr3' => '', 'skmbmn' => 'VF課', 'skmtel' => '029-240-7722', 'skmfax' => '029-219-2215', 'shudt' => '2018/12/02', 'hinnm' => 'だいこん', 'denno' => '2697850', 'suryo' => '-100.00', 'gokin' => 500, 'shzei' => -800, 'gsykei' => 10279, 'gshzei' => 821, 'ggokin' => 11100, 'skymd' => '2019年01月01日', 'title' => '請求書', 'jahno' => 1, 'nowdate' => '2019年07月12日', 'reprint' => 0, 'dspod' => 0, 'taxcd' => 'A' , 'hbydt' => 20181202, ], '1' => [ 'knrno' => '0001004_20181210__0_100_20190101', 'hancd' => '0001004', 'hannm' => '水戸上中妻', 'ssmdt' => '20181210', 'sekno' => '000382633', 'seiux' => 0, 'hanpos' => 311-4143, 'hanaddr1' => '水戸市大塚町1261-3', 'hanaddr2' => '', 'hanaddr3' => '', 'skmbmn' => 'VF課', 'skmtel' => '029-240-7722', 'skmfax' => '029-219-2215', 'shudt' => '2018/12/02', 'hinnm' => 'だいこん', 'denno' => '2697850', 'suryo' => '-100.00', 'gokin' => 700, 'shzei' => -800, 'gsykei' => 10279, 'gshzei' => 821, 'ggokin' => 11100, 'skymd' => '2019年01月01日', 'title' => '請求書', 'jahno' => 1, 'nowdate' => '2019年07月12日', 'reprint' => 0, 'dspod' => 0, 'taxcd' => 'A' , 'hbydt' => 20181202, ], '3' => [ 'knrno' => '0001004_20181210__0_100_20190101', 'hancd' => '0001004', 'hannm' => '水戸上中妻', 'ssmdt' => '20181210', 'sekno' => '000382633', 'seiux' => 0, 'hanpos' => 311-4143, 'hanaddr1' => '水戸市大塚町1261-3', 'hanaddr2' => '', 'hanaddr3' => '', 'skmbmn' => 'VF課', 'skmtel' => '029-240-7722', 'skmfax' => '029-219-2215', 'shudt' => '2018/12/02', 'hinnm' => 'だいこん', 'denno' => '2697850', 'suryo' => '-100.00', 'gokin' => 1000, 'shzei' => -800, 'gsykei' => 10279, 'gshzei' => 821, 'ggokin' => 11100, 'skymd' => '2019年01月01日', 'title' => '請求書', 'jahno' => 1, 'nowdate' => '2019年07月12日', 'reprint' => 0, 'dspod' => 0, 'taxcd' => 'B' , 'hbydt' => 20181202, ] ]; $aaa = []; $result = []; foreach($parm as $no => $value){ // 管理ID $groupKey1 = $value[$group1]; // 税率 $groupKey2 = $value[$group2]; $aaa[] = $value[$kin]; // $result[$groupKey1][$groupKey2] = array_sum($aaa); } var_dump($aaa); // $result[$groupKey1][$groupKey2] += $values[$kin]; // } // var_dump($result); ?>
Output for git.master, git.master_jit, rfc.property-hooks
array(3) { [0]=> int(500) [1]=> int(700) [2]=> int(1000) }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
55.78 ms | 401 KiB | 8 Q