increment
и decrement
для изменеия балансаpublic function updateBalance($bet_amount): void
{
$this->decrement('balance', $bet_amount);
}
UPDATE `users` SET `balance` = `balance` - $bet_amount WHERE id = ...
lockForUpdate()
чтобы исключить любые конфликты на уровне БД и тогда redis-локи в принципе можно убрать. try_files
location / {
try_files $uri $uri/ /index.php?$query_string;
}
$_SERVER['REQUEST_URI']
<?php
$array = [
1,2,3,4,5
];
$seed = 11111;
srand($seed);
$shuffled_array = $array;
shuffle($shuffled_array);
srand();
var_dump($shuffled_array);
prepareForValidation()
https://promokod.pikabu.ru/shops/5ka
curl -L -I "https://promokod.pikabu.ru/shops/5ka"
HTTP/1.1 200 OK
Server: nginx
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Vary: Accept-Encoding
Cache-Control: no-cache, private
Date: Fri, 06 Oct 2023 12:56:29 GMT
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 58
Set-Cookie: XSRF-TOKEN=eyJpdiI6ImZuTllpTWRIb2ZDalF5.......TkyOWY3In0%3D; expires=Fri, 13-Oct-2023 12:56:29 GMT; Max-Age=604800; path=/
<?php
$arr_seo = [ 5 => [ 'term_id' => 1680, 'perc' => 50 ], 6 =>[ 'term_id' => 1114, 'perc' => 27]];
$max_perc = 0;
$max_term_id = 0;
foreach($arr_seo as $key => $row) {
if($row['perc'] > $max_perc) {
$max_perc = $row['perc'];
$max_term_id = $row['term_id'];
}
}
var_dump($max_term_id);
<?php
$html = <<<HTML
<p class="p-1">p1</p><p class="p-2">p2</p>
<div class="wrap"><p class="p-3">p3</p></div><p class="p-4">p4</p><p class="p-5">p5</p>
HTML;
preg_match_all('!<p[^>]{0,}>(.*?)</p>!si', $html, $out);
var_dump($out[0][3]);
$out[1][3]