Заполненные PHP-массивы с элементами дат для проверки данных, операций с датами, вывода списков в формах и т.д.
$array = array(
1 => '01',
2 => '02',
3 => '03',
4 => '04',
5 => '05',
6 => '06',
7 => '07',
8 => '08',
9 => '09',
10 => '10',
11 => '11',
12 => '12',
13 => '13',
14 => '14',
15 => '15',
16 => '16',
17 => '17',
18 => '18',
19 => '19',
20 => '20',
21 => '21',
22 => '22',
23 => '23',
24 => '24'
);
$array = array(
1 => 'понедельник',
2 => 'вторник',
3 => 'среда',
4 => 'четверг',
5 => 'пятница',
6 => 'суббота',
7 => 'воскресенье'
);
$start = strtotime(date('Y-m-01'));
$finish = strtotime(date('Y-m-t'));
$array = array();
for($i = $start; $i <= $finish; $i += 86400) {
$list = explode('.', date('d.m.Y', $i));
$array[] = implode('.', $list);
}
print_r($array);
Результат:
Array
(
[0] => 01.10.2024
[1] => 02.10.2024
[2] => 03.10.2024
[3] => 04.10.2024
[4] => 05.10.2024
[5] => 06.10.2024
[6] => 07.10.2024
[7] => 08.10.2024
[8] => 09.10.2024
[9] => 10.10.2024
[10] => 11.10.2024
[11] => 12.10.2024
[12] => 13.10.2024
[13] => 14.10.2024
[14] => 15.10.2024
[15] => 16.10.2024
[16] => 17.10.2024
[17] => 18.10.2024
[18] => 19.10.2024
[19] => 20.10.2024
[20] => 21.10.2024
[21] => 22.10.2024
[22] => 23.10.2024
[23] => 24.10.2024
[24] => 25.10.2024
[25] => 26.10.2024
[26] => 27.10.2024
[27] => 28.10.2024
[28] => 29.10.2024
[29] => 30.10.2024
[30] => 31.10.2024
)
$start = 1990;
$finish = date('Y');
$array = array();
for($i = $start; $i <= $finish; $i += 1) {
$array[] = $i;
}
print_r($array);
Результат:
Array
(
[0] => 1990
[1] => 1991
[2] => 1992
[3] => 1993
[4] => 1994
[5] => 1995
[6] => 1996
[7] => 1997
[8] => 1998
[9] => 1999
[10] => 2000
[11] => 2001
[12] => 2002
[13] => 2003
[14] => 2004
[15] => 2005
[16] => 2006
[17] => 2007
[18] => 2008
[19] => 2009
[20] => 2010
[21] => 2011
[22] => 2012
[23] => 2013
[24] => 2014
[25] => 2015
[26] => 2016
[27] => 2017
[28] => 2018
[29] => 2019
[30] => 2020
[31] => 2021
[32] => 2022
[33] => 2023
[34] => 2024
)