Skip to content

Instantly share code, notes, and snippets.

@golubev-alex
Last active July 31, 2023 07:34
Show Gist options
  • Save golubev-alex/34a4ba468ba5a162340d58e06cf8e201 to your computer and use it in GitHub Desktop.
Save golubev-alex/34a4ba468ba5a162340d58e06cf8e201 to your computer and use it in GitHub Desktop.
// дебажим через логи в файл
$file = $_SERVER["DOCUMENT_ROOT"] .'/log.txt';
file_put_contents($file, $url . PHP_EOL, FILE_APPEND);
file_put_contents($file, $result . PHP_EOL, FILE_APPEND);
// склонение числительных
function num_word($value, $words, $show = true)
{
$num = $value % 100;
if ($num > 19) {
$num = $num % 10;
}
$out = ($show) ? $value . ' ' : '';
switch ($num) {
case 1: $out .= $words[0]; break;
case 2:
case 3:
case 4: $out .= $words[1]; break;
default: $out .= $words[2]; break;
}
return $out;
}
num_word($views, array('отзыв', 'отзыва', 'отзывов'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment