3v4l.org

run code in 300+ PHP versions simultaneously
<?php function fetch_fb_fans($id, $no_of_retries = 10, $pause = 500000 /* 500ms */){ $ret = array(); $matches = array(); $url = 'http://www.facebook.com/plugins/fan.php?connections=100&id=' . $id; $context = stream_context_create(array('http' => array('header' => 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0'))); for($a = 0; $a < $no_of_retries; $a++){ $like_html = file_get_contents($url, false, $context); preg_match_all('{href="https?://www\.facebook\.com/([a-zA-Z0-9._-]+)" data-jsid="anchor" target="_blank"}', $like_html, $matches); if(empty($matches[1])){ // failed to fetch any fans - convert returning array, cause it might be not empty return array_keys($ret); }else{ // merge profiles as array keys so they will stay unique $ret = array_merge($ret, array_flip($matches[1])); } // don't get banned as flooder usleep($pause); } return array_keys($ret); } print_r(fetch_fb_fans('527201224055828', 2, 400000));
Output for git.master, git.master_jit, rfc.property-hooks
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo for www.facebook.com failed: System error in /in/1iiBg on line 10 Warning: file_get_contents(http://www.facebook.com/plugins/fan.php?connections=100&id=527201224055828): Failed to open stream: php_network_getaddresses: getaddrinfo for www.facebook.com failed: System error in /in/1iiBg on line 10 Array ( )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
84.93 ms | 402 KiB | 8 Q