3v4l.org

run code in 300+ PHP versions simultaneously
<?php function _getRollingMonths($months = 12) { $currentTime = strtotime('2015-01-30'); $dates = array(); for($i=$months-1;$i>=0;$i--) { $dates[] = array( 'year' => date('Y', strtotime("first day of -$i months", $currentTime)), 'month' => date('m', strtotime("first day of -$i months", $currentTime)), 'monthName' => date('M', strtotime("first day of -$i months", $currentTime)) ); } return $dates; } function _getMonths($year = null) { if (!isset($year)) { $year = date('Y'); } $dates = array(); for($month=1;$month<=12;$month++) { $dates[] = array( 'year' => date('Y', strtotime("$year-$month-01")), 'month' => date('m', strtotime("$year-$month-01")), 'monthName' => date('M', strtotime("$year-$month-01")) ); } return $dates; } function _getYTDMonths($year = null) { if (!isset($year)) { $year = date('Y'); } $dates = array(); for($i=date('m')-1;$i>=0;$i--) { $dates[] = array( 'year' => $year, 'month' => date('m', strtotime("first day of -$i months")), 'monthName' => date('M', strtotime("first day of -$i months")) ); if (date('m', strtotime("-$i months")) == date('m')) { $dates[count($dates)-1]['day'] = date('d', strtotime("-$i months")); } } return $dates; } function debug($var) { echo "<pre>"; print_r($var); echo "</pre>"; } debug(_getYTDMonths(2015));
Output for git.master, git.master_jit, rfc.property-hooks
<pre>Array ( [0] => Array ( [year] => 2015 [month] => 01 [monthName] => Jan ) [1] => Array ( [year] => 2015 [month] => 02 [monthName] => Feb [day] => 02 ) [2] => Array ( [year] => 2015 [month] => 03 [monthName] => Mar [day] => 30 ) ) </pre>

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