3v4l.org

run code in 300+ PHP versions simultaneously
<?php $cms = Array ( '0' => Array ( 'id' => 31, 'day_date' => '2020-01-30 00:00:00', 'new_visitors' => 459 ), '1' => Array ( 'id' => 32, 'day_date' => '2020-01-31 00:00:00', 'new_visitors' => 338 ), '2' => Array ( 'id' => 33, 'day_date' => '2020-02-01 00:00:00', 'new_visitors' => 242 ), '3' => Array ( 'id' => 34, 'day_date' => '2020-02-02 00:00:00', 'new_visitors' => 219 ) ); $tmp_array = array(); foreach ($cms as $key => $val) { $cDate = date('Ym', strtotime($val['day_date'])); if (array_key_exists($cDate, array_keys($tmp_array))) { $tmp_array[$cDate]['new_visitors'] += $val['new_visitors']; } else { $tmp_array[$cDate]['new_visitors'] = $val['new_visitors']; } $tmp_array[$cDate]['ids'][] = $val['id']; } print_r($tmp_array);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [202001] => Array ( [new_visitors] => 338 [ids] => Array ( [0] => 31 [1] => 32 ) ) [202002] => Array ( [new_visitors] => 219 [ids] => Array ( [0] => 33 [1] => 34 ) ) )

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:
32.28 ms | 402 KiB | 8 Q