3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = Array ( 0 => Array ( 'member_id' => 6, 'total' => 1, 'sorting' => 0 ), 1 => Array ( 'member_id' => 7, 'total' => 2, 'sorting' => 1 ) ); $b = Array ( 0 => Array ( 'member_id' => 2, 'total' => 3 ), 1 => Array ( 'member_id' => 6, 'total' => 1 ), 2 => Array ( 'member_id' => 7, 'total' => 2 ) ); $new_array = []; foreach ($a as $key => $data) { $new_array[$key]['member_id'] = $data['member_id']; foreach ($b as $key_1 => $data_1) { if ($data['member_id'] == $data_1['member_id']) { $new_array[$key]['total'] = $data_1['total']; if (isset($data_1['sorting'])) { $new_array[$key]['sorting'] = $data_1['sorting']; } else { $new_array[$key]['sorting'] = $data['sorting']; } break; } else { $new_array[$key]['total'] = 0; $new_array[$key]['sorting'] = $data['sorting']; } } } $new_array1 = []; foreach ($b as $key => $data) { if ($data['member_id'] != isset($new_array[$key]['member_id'])) { $new_array1[$key]['member_id'] = $data['member_id']; $new_array1[$key]['total'] = $data['total']; if (!isset($data['sorting'])) { $new_array1[$key]['sorting'] = isset($new_array[$key]['sorting']) ? $new_array[$key]['sorting'] + 1 : "" ; } } } $array_merge = array_merge($new_array, $new_array1); print_r($array_merge);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => Array ( [member_id] => 6 [total] => 1 [sorting] => 0 ) [1] => Array ( [member_id] => 7 [total] => 2 [sorting] => 1 ) [2] => Array ( [member_id] => 7 [total] => 2 [sorting] => ) )

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