How to create a cumulative posts and members count

I need to show my users cumulative posts and members registered count by date. It has to be displayed in an array format like this

for posts

array(array(2011,08,02), 500)
array(array(2011,08,03), 520)
array(array(2011,08,04), 540)
array(array(2011,08,05), 560)
array(array(2011,08,06), 580)

the same case for members

iam using wordpress.com stats to for statistics, i cant figure out how to do this, could anyone help me...

Topic array registered posts Wordpress statistics

Category Web


Here is a very crude script I've knocked up to get what you are after:

<?php
require('wp-blog-header.php');

$posts = get_posts('numberposts=-1&order=ASC');

$posts_times = array();

foreach ($posts as $post) {
    $post_time = strtotime($post->post_date);
    $offset = $post_time % (60*60*24);
    $post_time -= $offset;
    $posts_times[$post_time]++;
}

$keys = array_keys($posts_times);

$running_count = 0;

$end_data = array();

for($i = $keys[0]; $i <= $keys[(count($keys)-1)]; $i += (60*60*24)) {
    $running_count += $posts_times[$i];
    $end_data[] = array(
        array(date("Y", $i), date("m", $i), date("d", $i)),
        $running_count
    );
}
echo "<pre>";
print_r($end_data);
?>

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.