<?php
function isSequence3($num) {
if ($num < 123) return false;
$digits = str_split($num);
$seq = 1;
for($i=1; $i<count($digits); $i++) {
if ($digits[$i] == ($digits[$i - 1] + 1)) $seq++;
else $seq = 1;
}
return $seq > 2;
}
$sum = 0;
for ($n=1; $n<=10000; $n++) {
if (isSequence3($n)) $sum += $n;
}
printf("Sum: %d", $sum);
function isSeq3(int $number) : bool
{
$prevDigit = 0;
$seqLen = 0;
while ($number > 0) {
$digit = $number % 10;
if ($digit === $prevDigit - 1) {
$seqLen += 1;
} else {
$seqLen = 1;
}
if ($seqLen === 3) {
return true;
}
$number = intdiv($number, 10);
$prevDigit = $digit;
}
return false;
}
$q = trim($_REQUEST["q"]);
надо будёт $q очистить от ненужных символов, как делали выше. RewriteRule ^dopoborudovanie/index\.php$ /service/dopolnitelnoe\-oborudovanie/? [L,R=301]
/wp-content/themes/НАЗВАНИЕ_ТЕМЫ
$users = ...;
$products = ...;
$days = [
'Понедельник' => 'UF_SELECT_MON',
...
];
$excelRows = [];
foreach ($users as $user) {
foreach ($days as $label => $field) {
$userDayProductsLabels = [];
$userDayProducts = $user[$field];
foreach ($userDayProducts as $id) {
$userDayProductsLabels[] = $products[$id];
}
if (empty($userDayProductsLabels)) {
continue;
}
$excelRows[] = [
$user['NAME'],
$label,
join(", ", $userDayProductsLabels),
];
}
}
foreach ($n as $keys => $values) {
if ($values["PROPERTY_DAYTIME_VALUE"] == 1366 && $values["PROPERTY_TYPE_VALUE"] == 1375) {
$arItem[0]["SUBCATEGORY"][0]["PRODUCTS"][$c]["ID"] = $values["ID"];
$arItem[0]["SUBCATEGORY"][0]["PRODUCTS"][$c]["NAME"] = $values["NAME"];
$arItem[0]["SUBCATEGORY"][0]["PRODUCTS"][$c]["PREVIEW_PICTURE"] = $values["DETAIL_PICTURE"];
$arItem[0]["SUBCATEGORY"][0]["PRODUCTS"][$c]["PREVIEW_TEXT"] = $values["DETAIL_TEXT"];
$arItem[0]["SUBCATEGORY"][0]["PRODUCTS"][$c]["PREVIEW_TEXT_TYPE"] = $values["DETAIL_TEXT_TYPE"];
$arItem[0]["SUBCATEGORY"][0]["PRODUCTS"][$c]["IMAGE_URL"] = $values["IMAGE_URL"];
$c++;
}
foreach ($n as $values) {
if ($values["PROPERTY_DAYTIME_VALUE"] == 1366 && $values["PROPERTY_TYPE_VALUE"] == 1375) {
$arItem[0]["SUBCATEGORY"][0]["PRODUCTS"][] = $values;
}
}