$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"));
$result = $pdo->query("SELECT `Nick`, `timestamp` FROM `Skins`")->fetchAll(PDO::FETCH_ASSOC);
$nick = $result[0]['Nick'];
$timestamp = $result[0]['timestamp']
$response = file_get_contents('"https://api.mojang.com/users/profiles/minecraft/"+$nick+"?at="+$timestamp');
$nick = urlencode($nick);
чтобы проходили спецсимволы и пробелы в url if ($search){
$words = explode(' ', $search);
foreach ($words as $word) {
$search = $db->Quote('%'.$db->escape( $word, true).'%');
$conds1[] = ' prod.title LIKE '.$search;
$conds2[] = ' a.adres LIKE '.$search;
$conds3[] = ' prod.fio LIKE '.$search;
}
$query1 = implode(' OR ', $conds1);
$query2 = implode(' OR ', $conds2);
$query3 = implode(' OR ', $conds3);
$query->where('( '.$query1.' ) OR ( '.$query2.' ) OR ( '.$query3.')');
}
function mb_count_chars($input) {
$l = mb_strlen($input, 'UTF-8');
$unique = array();
for($i = 0; $i < $l; $i++) {
$char = mb_substr($input, $i, 1, 'UTF-8');
if(!array_key_exists($char, $unique))
$unique[$char] = 0;
$unique[$char]++;
}
return $unique;
}
$input = "Когда Вам покажется, что цель недостижима, не изменяйте цель - изменяйте свой план действий. Конфуций";
print_r(mb_count_chars(preg_replace('/[^[:alnum:]]/u', '', mb_strtolower($input))) );
$start = '20:55';
$end = '00:05';
$float_start = floatval(str_replace(':', '.', $start));
$float_end = floatval(str_replace(':', '.', $end));
if ($float_start < $float_end) {
$date1 = new DateTime("2018-12-16 " . $start . ":00");
$date2 = new DateTime("2018-12-16 " . $end . ":00");
$interval = $date1->diff($date2);
} else {
$date1 = new DateTime("2018-12-16 " . $start . ":00");
$date2 = new DateTime("2018-12-17 " . $end . ":00");
$interval = $date1->diff($date2);
}
echo $interval->format('%H:%I');
$cookies = new Phalcon\Http\Response\Cookies();
$cookies->set(
'remember-me',
'some value',
time() + 15 * 86400
);
или через сервис $di->set(
'cookies',
function () {
$cookies = new Phalcon\Http\Response\Cookies();
$cookies->useEncryption(false);
return $cookies;
}
);