3v4l.org

run code in 300+ PHP versions simultaneously
<?php $current_path = 'http://www.liveinstyle.com/star-speak/the-ranveer-singh-royal-challenge-can-it-get-bolder-than-this-5656'; $social_share = array("http://graph.facebook.com/?id=", "http://cdn.api.twitter.com/1/urls/count.json?url=","http://api.pinterest.com/v1/urls/count.json?callback=jsonp&url=", "https://plusone.google.com/_/+1/fastbutton?url="); $share = 0; foreach($social_share as $social) { $url = $social. $current_path; $json_output = file_get_contents($url, TRUE); $json = json_decode($json_output, TRUE); if($social == "http://graph.facebook.com/?id="){ $share += $json['shares']; } elseif($social == "https://plusone.google.com/_/+1/fastbutton?url="){ $doc = new DOMDocument(); @$doc->loadHTML($json_output); $counter=$doc->getElementById('aggregateCount'); $share += $counter->nodue; } else{ $share += $json['count']; } } print $share;

preferences:
41.74 ms | 402 KiB | 5 Q