function formatTier(tier) {
tier = tier.replace("10", "challenger").replace("0", "unranked").replace("1", "iron").replace("2", "bronze").replace("3", "silver").replace("4", "gold").replace("5", "platinum").replace("6", "emerald").replace("7", "diamond").replace("8", "master").replace("9", "grandmaster");
return tier;
}
<?php
$x = 400;
$y = 0.75;
$z = 1.5;
$test = ($x + 2 * $y - ($x / 2 + 2 * $z)) / 2;
print $test;
// 99.25
public function handle(Request $request, Closure $next): Response
{
$response = $next($request);
$json = $response->getData();
$json['config'] = ...;
$response->setData($json);
return $response;
}
connect('feedback', $regArr);
Засунь в блок if (isset($_POST['btn'])) {
<?php
if (isset($_POST['btn'])) {
$names = htmlspecialchars(trim($_POST['userName']));
$email = htmlspecialchars(trim($_POST['userEmail']));
$message = htmlspecialchars(trim($_POST['userMessage']));
$regArr = [
'fb_name' => $names,
'fb_email' => $email,
'fb_message' => $message,
];
// Вызываем функцию записи в базу данных из файла connect.php
connect('feedback', $regArr);
}
?>
.then( response => {
if (response.status >= 200) {
// console.log(response)
return Promise.resolve(response)
} else {
return Promise.reject(new Error(response.statusText)) //new MyFetchError
}
})
.then(response => response.json())
.then(success => console.log(success))
.catch...
const getShuffledArray = (min, max) => {
const randoms = Array(max - min + 1).fill(min).map((n, i) => n + i);
for (let i = randoms.length - 1; i > 0; i -= 1) {
const r = Math.floor(Math.random() * (i + 1));
[randoms[i], randoms[r]] = [randoms[r], randoms[i]];
}
return randoms;
}
getShuffledArray(5, 10);
// [ 6, 10, 7, 5, 8, 9 ]
getShuffledArray(5, 10);
// [ 9, 6, 5, 7, 8, 10 ]
$result = array();
if (!$stmt->rowCount()) {
$result['error_login'] = "Пользователь с такими данными не зарегистрирован";
echo json_encode($result, JSON_UNESCAPED_UNICODE);
}
...
$_SESSION['user_id'] = $user['id'];
$result['us3r_id'] = $_SESSION['user_id'];
echo json_encode($result, JSON_UNESCAPED_UNICODE);
dataType: "json"
const jsonData = await getCategories()...