3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php for ($i = 0; $i <= 12; $i++) { $months[] = date("m/Y", strtotime( date( 'Y-m-01' )." -$i months")); } print_r($months);
based on 0sGHn
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.3.0beta1
Array ( [0] => 07/2017 [1] => 06/2017 [2] => 05/2017 [3] => 04/2017 [4] => 03/2017 [5] => 02/2017 [6] => 01/2017 [7] => 12/2016 [8] => 11/2016 [9] => 10/2016 [10] => 09/2016 [11] => 08/2016 [12] => 07/2016 )