Setting PHP variables for 2 years back and 2 years in the future The following code gets years (dates), 1 and 2 years back (for example 2017 - 2016) and 1 and 2 years into the future (for example 2019 - 2020). Now PHP is not my expertise so I would like to get some help cleaning this up.

Is there a different approach I should use when doing this? 

//Filter jaren
$year = date("Y");
$yearBack = $year;
$yearBack--;
$yearDoubleBack = $yearBack;
$yearDoubleBack--;
$yearAhead = $year;
$yearAhead++;
$YearDoubleAhead = $yearAhead;
$YearDoubleAhead++;
Only three-four line code rquired for getting required result:-

&lt;?php

$date = date("Y"); //current year

$date_range = range($date-2, $date+2);//get year range

//print_r($date_range); //print year range

echo implode(',',$date_range);//comma seperated date range


Output:- https://eval.in/944817