3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array1 = [ ['subscribers' => 2, 'dt_date' => '2014-02-27'], ['subscribers' => 2, 'dt_date' => '2014-02-25'], ['subscribers' => 1, 'dt_date' => '2014-02-07'] ]; $array2 = [ ['unsubscribers' => 1, 'dt_date' => '2014-02-27'], ['unsubscribers' => 1, 'dt_date' => '2014-02-01'] ]; $result = []; $default = array_fill_keys(['subscribers', 'unsubscribers'], 0); foreach (array_merge($array1, $array2) as $row) { $result[$row['dt_date']] = array_merge($result[$row['dt_date']] ?? $default, $row); } var_export(array_values($result));
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => array ( 'subscribers' => 2, 'unsubscribers' => 1, 'dt_date' => '2014-02-27', ), 1 => array ( 'subscribers' => 2, 'unsubscribers' => 0, 'dt_date' => '2014-02-25', ), 2 => array ( 'subscribers' => 1, 'unsubscribers' => 0, 'dt_date' => '2014-02-07', ), 3 => array ( 'subscribers' => 0, 'unsubscribers' => 1, 'dt_date' => '2014-02-01', ), )

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:
29.37 ms | 404 KiB | 8 Q