3v4l.org

run code in 300+ PHP versions simultaneously
<?php $reserved_dates = array( '2023-12-03', '2023-12-10', '2023-12-17', '2023-12-24', '2023-12-31', '2024-01-07', '2024-01-14', '2024-01-21', '2024-01-28', '2024-02-04', '2024-02-11', '2024-02-18', '2024-02-25', '2024-12-01', '2023-12-03', '2024-12-08', '2024-12-15', ); $data = []; foreach($reserved_dates as $d){ list($year, $month) = explode("-", $d); $data[ $year ]['year'] = $year; $data[ $year ]['months'][ $month ] = $data[ $year ]['months'][ $month ] ?? []; $data[ $year ]['months'][ $month ]['monthName'] = date("F", strtotime($d)); $data[ $year ]['months'][ $month ]['paid'] = true; // or false whatever $data[ $year ]['months'][ $month ]['dates'] = $data[ $year ]['months'][ $month ]['dates'] ?? []; $data[ $year ]['months'][ $month ]['dates'][] = $d; } foreach($data as &$months){ foreach($months['months'] as &$each_month){ usort($each_month['dates'], fn($a, $b) => DateTime::createFromFormat('!Y-m-d', $a) <=> DateTime::createFromFormat('!Y-m-d', $b)); } $months['months'] = array_values($months['months']); } $data = array_values($data); print_r($data);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => Array ( [year] => 2023 [months] => Array ( [0] => Array ( [monthName] => December [paid] => 1 [dates] => Array ( [0] => 2023-12-03 [1] => 2023-12-03 [2] => 2023-12-10 [3] => 2023-12-17 [4] => 2023-12-24 [5] => 2023-12-31 ) ) ) ) [1] => Array ( [year] => 2024 [months] => Array ( [0] => Array ( [monthName] => January [paid] => 1 [dates] => Array ( [0] => 2024-01-07 [1] => 2024-01-14 [2] => 2024-01-21 [3] => 2024-01-28 ) ) [1] => Array ( [monthName] => February [paid] => 1 [dates] => Array ( [0] => 2024-02-04 [1] => 2024-02-11 [2] => 2024-02-18 [3] => 2024-02-25 ) ) [2] => Array ( [monthName] => December [paid] => 1 [dates] => Array ( [0] => 2024-12-01 [1] => 2024-12-08 [2] => 2024-12-15 ) ) ) ) )

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:
40.47 ms | 415 KiB | 5 Q