file_put_contents(APP_PATH . '/conf/uniq_id.txt', $numb);
//логируем стек вызовов
ob_start();
debug_print_backtrace();
$trace = ob_get_contents();
ob_end_clean();
file_put_contents(APP_PATH . '/conf/backtrace.txt', $trace, FILE_APPEND);
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']
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]
<?php
$maxArray = [5, 10, 7, 18, 3];
$result = [];
for($i4 = 0; $i4 <= $maxArray[4]; $i4++) {
for($i3 = 0; $i3 <= $maxArray[3]; $i3++) {
for($i2 = 0; $i2 <= $maxArray[2]; $i2++) {
for($i1 = 0; $i1 <= $maxArray[1]; $i1++) {
for($i0 = 0; $i0 <= $maxArray[0]; $i0++) {
$result[] = [$i0, $i1, $i2, $i3, $i4];
}
}
}
}
}
echo join(',', $result[0])."\n";
echo join(',', $result[1])."\n";
echo join(',', $result[2])."\n";
echo join(',', $result[3])."\n";
echo join(',', $result[40127])."\n";
//0,0,0,0,0
//1,0,0,0,0
//2,0,0,0,0
//3,0,0,0,0
//5,10,7,18,3