Quick actions

cmd+k|ctrl+k

Navigation

Languages

Statistical data that can be queried according to date with array/JSON

Snippet info

Language

Php

Visibility

public

Author

mertskaplan

Created

2016-12-07T00:13:36Z

Updated

2016-12-07T00:14:36Z

<?php

$statics = ['1481069313' => ['added' => 2, 'removed' => 8],'1481072913' => ['added' => 7, 'removed' => 12], '1481674113' => ['added' => 18, 'removed' => 5]];

function getStatics($staticsCat, $firstTimestamp, $lastTimestamp) {
    global $statics;
    foreach($statics as $timestamp => $cat){
        if ($timestamp >= $firstTimestamp && $timestamp <= $lastTimestamp) {
            $count += $cat["$staticsCat"];
        }
    }
    echo $count;
}

getStatics('added', strtotime('2016-12-06 00:00:00'), strtotime('2016-12-08 00:00:00'));
INFO