Last updated on January 17, 2018
In my recent client project, I am writing filters on data with different categories and where I need to filter data with year also, I wanted to use range function there, but range function generates different keys(I want the keys to be the same as the value(year)). here is the trick
$years = array_combine(range(2000,2014),range(2000,2014)); print_r($years); //output : /* Array ( [2000] => 2000 [2001] => 2001 [2002] => 2002 [2003] => 2003 [2004] => 2004 [2005] => 2005 [2006] => 2006 [2007] => 2007 [2008] => 2008 [2009] => 2009 [2010] => 2010 [2011] => 2011 [2012] => 2012 [2013] => 2013 [2014] => 2014 )*/