function get_fo($distr) {
$data = [
'ЦФО' => ['31', '32', '33', '36', '37', '40', '46', '48', '50', '57', '62', '67', '68', '69', '71', '76'],
'СЗФО' => ['10', '11', '29', '83', '35', '39', '47', '51', '53', '60'],
'ЮФО' => ['1', '5', '6', '7', '8', '9', '15', '95', '23', '26', '30', '34', '61'],
'ПФО' => ['2', '12', '13', '16', '18', '21', '43', '59', '52', '56', '59', '63', '64', '73'],
'УФО' => ['45', '66', '72', '86', '74', '89'],
'СФО' => ['3', '4', '17', '19', '22', '24', '38', '42', '54', '55', '70'],
'ДФО' => ['14', '41', '25', '27', '28', '49', '65', '79', '87'],
'Крым' => ['92', '82'],
];
foreach ($data as $fo => $value) {
if (in_array($distr, $value)) {
return $fo;
}
}
return 'fff';
}
<?php
$arrX = array(2, 4, 6, 8, 10, 12, 14, 16, 18, 20);
$arrY = array(1, 3, 5, 7, 9, 11, 13, 15, 17, 19);
$iter = 100000;
$start = microtime(true);
$number_p = 3.14;
$distance = 40 / 5;
$total = 0;
$cntX = count($arrX);
$cntY = count($arrY);
$var0 = $number_p * $distance;
for ($a = 0; $a < $iter; $a++) {
$varA = $number_p + $a;
foreach ($arrX as $i => $x) {
$varB = $x * $varA;
foreach ($arrY as $j => $y) {
$value = $varB * ($y + $var0);
$total += $value;
switch ($i) {
case 3:
$total += 100;
break;
case 6:
$total += 500;
break;
case 9:
$total += 1000;
break;
}
if ($value % 2 == 0) {
$total = $total + 1;
} else {
$total = $total + 2;
}
}
}
}
echo "Total: $total";
$time = microtime(true) - $start;
echo "<br>Script time is $time";
while (true) {
$sql = 'UPDATE `score` AS s, `auto1` AS a
SET s.score = s.score + (a.`card` * 3.75 + a.`cardrack` * 7.5 + a.`videocardroom` * 15)
WHERE s.vk_id = a.vk_id'
$db->query($sql);
// sleep(1); // Подозреваю что апдейт будет выполнятся больше секунды
}