-
Notifications
You must be signed in to change notification settings - Fork 0
/
birthday.php
55 lines (50 loc) · 1.35 KB
/
birthday.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
error_reporting(-1);
ini_set('display_errors', 'On');
/**
* Created by PhpStorm.
* User: Михаил
* Date: 21.01.2016
* Time: 18:36
*/
echo '<p>Сортировка по дате рождения</p>';
$arrays = [
[
'first_name' => 'Григорий',
'last_name' => 'Терентьев',
'city' => 'Москва',
'birthday' => '05.05.1984'
],
[
'first_name' => 'Владислав',
'last_name' => 'Фомин',
'city' => 'Санкт-Петербург',
'birthday' => '09.06.1972'
],
[
'first_name' => 'Антон',
'last_name' => 'Калашников',
'city' => 'Новосибирск',
'birthday' => '08.02.1972'
],
[
'first_name' => 'Юрий',
'last_name' => 'Терентьев',
'city' => 'Москва',
'birthday' => '07.02.1975'
],
[
'first_name' => 'Антон',
'last_name' => 'Лазарев',
'city' => 'Санкт-Петербург',
'birthday' => '10.07.1982'
]
];
function sortByBirthday ($first, $second) {
return strtotime($first['birthday']) <=> strtotime($second['birthday']);
}
usort($arrays, 'sortByBirthday');
echo '<pre>';
print_r($arrays);
echo '</pre>';
//echo strtotime('10.07.1972');