{% else-1 %}
Использование:

<img src="<?php current_season() ?>" alt="" />

                        
function current_season() {
04
$icons = array(
05
"spring" => "images/spring.png",
06
"summer" => "images/summer.png",
07
"autumn" => "images/autumn.png",
08
"winter" => "images/winter.png"
09
);
10

11
$day = date("z");
12

13
$spring_starts = date("z", strtotime("March 21"));
14
$spring_ends = date("z", strtotime("June 20"));
15

16
$summer_starts = date("z", strtotime("June 21"));
17
$summer_ends = date("z", strtotime("September 22"));
18

19
$autumn_starts = date("z", strtotime("September 23"));
20
$autumn_ends = date("z", strtotime("December 20"));
21

22
if( $day >= $spring_starts && $day <= $spring_ends ) :
23
$season = "spring";
24
elseif( $day >= $summer_starts && $day <= $summer_ends ) :
25
$season = "summer";
26
elseif( $day >= $autumn_starts && $day <= $autumn_ends ) :
27
$season = "autumn";
28
else :
29
$season = "winter";
30
endif;
31

32
$image_path = $icons[$season];
33

34
echo $image_path;
35
}
-2 32 0
Без комментариев...