$data = json_decode($json, true);
$result = array_filter(
$data,
function ($value) use ($params) {
if(isset($params["payment"]) && !in_array($params["payment"], $value['payment_methods'])) {
return false;
}
if(isset($params["reviews"]) && $params["reviews"] > $value['reviews']) {
return false;
}
if(isset($params["amount"]) && $params["amount"] > $value['seller_buyer_limit_max']) {
return false;
}
//Код для остальных фильтров если надо
return true;
}
);
function binanceFilterFn($params) {
return function($value) use ($params) {
if(isset($params["payment"]) && !in_array($params["payment"], $value['payment_methods'])) {
return false;
}
//...
}
}
$result = array_filter($data, binanceFilterFn($params));
$balance = function($alias) use ($json) {
$Array = json_decode($json, true)["accounts"];
$key = array_search($alias, array_column($Array, "alias"));
return $key && isset($Array[$key]["balance"]["amount"])?$Array[$key]["balance"]["amount"]:null;
};
var_dump($balance("qw_wallet_rub"));
var_dump($balance("mc_beeline_rub"));
$arr = \json_decode($a, true);
$reducer = function ($carry, $item): float {
if ('qw_wallet_rub' === $item['alias'] ?? null) {
return $carry + $item['balance']['amount'] ?? 0.0;
}
return (float)$carry;
};
$result = \array_reduce($arr['accounts'], $reducer);
$query = "SELECT Name, CountryCode FROM City ORDER by ID DESC LIMIT 50,1";
$result = $mysqli->query($query);
$row = $result->fetch_assoc();
$row = $mysqli->query($query)->fetch_assoc();
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
$mysqli->set_charset("utf8mb4");
__FILE__
/ __DIR__
SELECT * FROM (
(SELECT *, 0 as `order`
FROM `table`
WHERE `smen` <= 0 AND `cash` > 500
ORDER BY `cash` DESC
LIMIT 1)
UNION
(SELECT *, 1
FROM `table`
WHERE `smen` <= 1 AND `cash` > 500
ORDER BY `cash` DESC
LIMIT 1)
UNION
(SELECT *, 2
FROM `table`
WHERE `smen` <= 0
ORDER BY `cash` DESC
LIMIT 1)
UNION
(SELECT *, 3
FROM `table`
WHERE `smen` <= 1
ORDER BY `cash` DESC
LIMIT 1)
)
ORDER BY `order`
LIMIT 1
echo "\xFF\xFE";
$users = [
'u101',
'u402',
'u503',
'u703',
'u114',
'u148',
'u152',
'u173',
'u134'
];
$string = implode(" OR ", $users); // u101 OR u402 OR u503 OR u703 OR u114 OR u148 OR u152 OR u173 OR u134;
"... WHERE `akk` IN (" . implode(",", $users) . ");";