Skip to content

Instantly share code, notes, and snippets.

@prinsss
Created January 10, 2017 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prinsss/b598abd560c809ea64667d284fc01f0f to your computer and use it in GitHub Desktop.
Save prinsss/b598abd560c809ea64667d284fc01f0f to your computer and use it in GitHub Desktop.
Calculate the total number of comments posted last year from Diqus exported XML file.
<?php
/**
* @Author: printempw
* @Date: 2017-01-10 22:44:20
* @Last Modified by: printempw
* @Last Modified time: 2017-01-10 23:09:35
*/
$xmlString = file_get_contents('./blessing-studio-2017-01-10T14_38_39.483395-all.xml');
$xml = new SimpleXMLElement($xmlString);
$sum = 0;
foreach ($xml->post as $post) {
// do not add my comments in
if (strtotime($post->createdAt) > 1451631600 && $post->author->name != 'printempw') {
// print_r($post);
$sum++;
}
}
exit("Total comments number of last year: $sum \n");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment