var arr = [{'id':1, 'amount':123, 'currency' : 'CHF'},{'id':2, 'amount':321, 'currency' : 'USD'},{'id':3, 'amount':4324, 'currency' : 'UAH'},{'id':4, 'amount':45645, 'currency' : 'USD'},{'id':5, 'amount':8972, 'currency' : 'CHF'}];
var result = {};
arr.forEach(function(item){
if(!result.hasOwnProperty(item.currency))
result[item.currency] = 0;
result[item.currency] += item.amount;
});
console.log(result)
//Object {CHF: 9095, USD: 45966, UAH: 4324}
.logo{
width: 100px;
height: 20px;
position: relative;
background-size: cover;
background-image: url(logo.png);
}
.logo__loaded{
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
width: 0%;
background-size: cover;
background-image: url(logo2.png);
}
<div class="logo">
<div class="logo__loaded" style="70%"></div>
</div
function articles_all() {
$art1 = ["id"=>1, "title"=>"Title1", "date"=>"12-10-2015", "content"=>"Content1"];
$art2 = ["id"=>2, "title"=>"Title2", "date"=>"13-10-2015", "content"=>"Content2"];
$arr[0] = $art1;
$arr[1] = $art2;
return $arr;
}
// PHP 5.4+
function articles_all() {
return [
['id' => 1, 'title' => 'Title1', 'date' => '12-10-2015', 'content' => 'Content1'],
['id' => 2, 'title' => 'Title2', 'date' => '13-10-2015', 'content' => 'Content2']
];
}
function cacheImage(url) {
var img = new Image();
img.src = url;
}
cacheImage('/page2.png');
cacheImage('/page3.png');
img.cache {
display: none;
}
<html>
<head>
*подключаем стиль*
*подключаем скрипт*
</head>
<body>
Главная страница
<img class='cache' src='/image2.png'>
</body>
</html>