3v4l.org

run code in 300+ PHP versions simultaneously
<?php $left = Array ( 0 => Array ( 'UserID' => 6835406 ), 1 => Array ( 'UserID' => 8418097 ), 2 => Array ( 'UserID' => 9889987 ), 3 => Array ( 'UserID' => 9899999 ) ); $right = Array ( 0 => Array ( 'Amount' => 0.00, 'UserID' => 6835406 ), 1 => Array ( 'Amount' => 0.00, 'UserID' => 8418097 ), 2 => Array ( 'UserID' => 9889987 ) ); function combineArray($left, $right){ $finalArray = array(); foreach($left as $lft){ foreach($right as $rgt){ if($lft['UserID'] == $rgt['UserID']){ $finalArray[$lft['UserID']]['UserID'] = $lft['UserID']; $finalArray[$lft['UserID']]['Amount'] = (isset($rgt['Amount']) ? $rgt['Amount'] : NULL); break; }else{ $finalArray[$lft['UserID']]['UserID'] = $lft['UserID']; $finalArray[$lft['UserID']]['Amount'] = NULL; } } } return $finalArray = array_values($finalArray); } var_dump(combineArray($left, $right));
Output for git.master, git.master_jit, rfc.property-hooks
array(4) { [0]=> array(2) { ["UserID"]=> int(6835406) ["Amount"]=> float(0) } [1]=> array(2) { ["UserID"]=> int(8418097) ["Amount"]=> float(0) } [2]=> array(2) { ["UserID"]=> int(9889987) ["Amount"]=> NULL } [3]=> array(2) { ["UserID"]=> int(9899999) ["Amount"]=> NULL } }

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:
75.51 ms | 406 KiB | 5 Q