Skip to content

Instantly share code, notes, and snippets.

@Committing
Last active June 25, 2016 19:08
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 Committing/06c88b38a192968d96a23446988eda93 to your computer and use it in GitHub Desktop.
Save Committing/06c88b38a192968d96a23446988eda93 to your computer and use it in GitHub Desktop.
Order parliament.uk votes by country
<?php
$res = file_get_contents('https://petition.parliament.uk/petitions/131215.json');
$select = json_decode($res);
$output = array();
$count = 0;
foreach ($select->data->attributes->signatures_by_country as $var) {
$output[$var->name] = $var->signature_count;
$count = $count + $var->signature_count;
}
arsort($output);
echo 'Total votes: ' . number_format($count) . '<br /><br />';
echo '<pre>';
print_r($output);
echo '</pre>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment