<?
<?php
$json = file_get_contents('http://api.steampowered.com/ISteamUserStats/GetUserStatsForGame/v0002/?appid=730&key='.$steam_api_key.'&steamid='.$user_steam_id); //Получение JSON
// true, чтобы на выходе был ассоциативный массив, а не \stdClass (для PHP 7 неактуально, т.к. array_column может работать с массивами объектов)
$data = json_decode($json, true);
$stats = array_column($data['playerstats']['stats'], 'value', 'name');
echo $stats['total_deaths'];
/**
* @return void
*/
public function processUpdates()
{
$updates = $this->api->getUpdates();
$lastUpdateId = null;
foreach ($updates as $update) {
$lastUpdateId = $update->getUpdateId();
$this->processUpdate($update);
}
if ($lastUpdateId) {
$this->api->getUpdates($lastUpdateId + 1, 1);
}
}
The Mongo PHP Adapter is a userland library designed to act as an adapter between applications relying on ext-mongo and the new driver (ext-mongodb).
It provides the API of ext-mongo built on top of mongo-php-library, thus being compatible with PHP 7.
In order to have the dump() function always available when running any PHP code, you can install it globally on your computer:
- Run composer global require symfony/var-dumper;
- Add auto_prepend_file = ${HOME}/.composer/vendor/autoload.php to your php.ini file;
- From time to time, run composer global update to have the latest bug fixes.
$(window).bind('statechange', function () {
var State = History.getState();
var url = State.url;
var data = State.data;
if (ajaxRequest) {
ajaxRequest.abort();
} else {
$resultContainer.html('<div class="ajax-loader" style="position:relative;"><img src="http://i.imgur.com/6RMhx.gif" /></div>');
}
ajaxRequest = $.ajax({
url: url,
data: data,
dataType: 'json',
success: function (data, textStatus, jqXHR) {
$resultContainer.html(data.content);
if (data.form) {
$filterForm.html(data.form);
filterFormInitCallback();
}
ajaxRequest = null;
},
error: function (jqXHR, textStatus, errorThrown) {
if ('abort' != textStatus) {
document.location.href = url;
}
return false;
}
});
});
$filterForm.submit(function () {
var query = $(this).formSerialize();
// decodeURIComponent т.к. formSerialize выдает закодированный урл, а histoty.js пытается закодировать его еще раз
History.pushState(null, document.title, '?' + window.decodeURIComponent(query));
return false;
});
<?php
$name = 'name';
$title = 'title';
$text = 'text';
$body = <<<BODY
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>$title</title>
</head>
<body>
<h1>$title<h1>
<p>$text</p>
</body>
</html>
BODY;
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . sprintf('%s.html', $name));
header('Content-Length: ' . sizeof($body));
echo $body;
$dateFormatter = new \IntlDateFormatter(
'ru',
\IntlDateFormatter::FULL,
\IntlDateFormatter::FULL,
new \DateTimeZone('UTC'),
IntlDateFormatter::GREGORIAN,
'dd MMM yyyy HH:mm:ss'
);
$string = '06 окт. 2014 21:45:17';
var_dump($string);
$timestamp = $dateFormatter->parse($string);
$test = new \DateTime(sprintf('@%s UTC', $timestamp));
var_dump($test);