3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr1 = [ ['customer_id' => 1, 'Expire' => '2019-05-14', 'paid' => 1], ['customer_id' => 2, 'Expire' => '2019-06-20', 'paid' => 0], ['customer_id' => 2, 'Expire' => '2019-06-21', 'paid' => 1], ]; $arr2 = [ ['id' => 3943, 'customer_id' => 1, 'Expire' => '2019-05-14'], ['id' => 3944, 'customer_id' => 1, 'Expire' => '2019-05-14'], ['id' => 4713, 'customer_id' => 2, 'Expire' => '2019-06-20'], ['id' => 4714, 'customer_id' => 2, 'Expire' => '2019-06-21'] ]; foreach ($arr2 as &$a) { // Find the sub-array of $arr1 that matches this array's date and ID $arr1_match = array_filter($arr1, function($v) use ($a) { return $v['customer_id'] == $a['customer_id'] && $v['Expire'] == $a['Expire']; }); // Get the first element from the result $paid = reset($arr1_match)['paid']; // Append the paid-value to this array (done by reference) $a['paid'] = $paid; } print_r($arr2);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => Array ( [id] => 3943 [customer_id] => 1 [Expire] => 2019-05-14 [paid] => 1 ) [1] => Array ( [id] => 3944 [customer_id] => 1 [Expire] => 2019-05-14 [paid] => 1 ) [2] => Array ( [id] => 4713 [customer_id] => 2 [Expire] => 2019-06-20 [paid] => 0 ) [3] => Array ( [id] => 4714 [customer_id] => 2 [Expire] => 2019-06-21 [paid] => 1 ) )

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.51 ms | 402 KiB | 8 Q