3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr1 = ["101","206", "206"]; $arr2 = ["PA701", "PA700", "PA700"]; $arr3 = ["2022-04-01", "2022-04-07", "2022-04-07"]; $arr4 = [70, 1040, 1625]; //expected Result $res1 = ["101","206"]; $res2 = ["PA701", "PA700"]; $res3 = ["2022-04-01", "2022-04-07"]; $res4 = [70, 2665]; foreach($arr1 as $k=>$val) { if(isset($arr1[$k+1])) { if($arr1[$k] == $arr1[$k+1] && $arr2[$k] == $arr2[$k+1] && $arr3[$k] == $arr3[$k+1]) { unset($arr1[$k+1]); unset($arr2[$k+1]); unset($arr3[$k+1]); $arr4[$k] += $arr4[$k+1]; unset($arr4[$k+1]); } } } print_r($arr1); print_r($arr2); print_r($arr3); print_r($arr4);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => 101 [1] => 206 ) Array ( [0] => PA701 [1] => PA700 ) Array ( [0] => 2022-04-01 [1] => 2022-04-07 ) Array ( [0] => 70 [1] => 2665 )

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:
97.73 ms | 405 KiB | 5 Q