php function ru_ending number titles cases array return number titles

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
<?php
function ru_ending($number,$titles){
$cases = array (2, 0, 1, 1, 1, 2);
return $number." ".$titles[ ($number%100>4 && $number%100<20)? 2: $cases[min($number%10, 5)] ];
}
function ageofmysite($y,$m,$d){
return ru_ending((date(«Y»,(time()-mktime(0,0,0,$m,$d,$y)))-1970),array('год','года','лет')).' '.ru_ending(date(«n»,(time()-mktime(0,0,0,$m,$d,$y))),array('месяц','месяца','месяц')).' '.ru_ending(date(«j»,(time()-mktime(0,0,0,$m,$d,$y))),array('день','дня','дней'));
}
echo ageofmysite($_GET['y'],$_GET['m'],$_GET['d']);