Advertisement
Guest User

Untitled

a guest
Jun 25th, 2016
608
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. <?php
  2.  
  3. $json = file_get_contents("https://petition.parliament.uk/petitions/131215.json");
  4.  
  5. $decoded = json_decode($json);
  6.  
  7. print "Title: ".$decoded->data->attributes->action."\n";
  8. print "Background: ".$decoded->data->attributes->background."\n";
  9. print "Created at: ".$decoded->data->attributes->created_at."\n";
  10.  
  11. //var_dump($decoded->data->attributes->signatures_by_country);
  12.  
  13. $total = 0;
  14.  
  15. print "---------------RESULTS BY COUNTRY----------------------\n";
  16.  
  17. foreach($decoded->data->attributes->signatures_by_country as $entry) {
  18. print $entry->name." - ".$entry->signature_count."\n";
  19. $total = $total + $entry->signature_count;
  20. }
  21.  
  22. print "-------------------------------------------\n";
  23.  
  24. print "Total: ".$total."\n";
  25.  
  26.  
  27. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement