Games PHP Web Trends

Get twitter follower count in php

Twitter API 1.0 is deprecated and is no longer active. With the REST 1.1 API, you need oAuth authentication to retrieve data from Twitter.

require_once( 'TwitterAPIExchange.php' ); //get it from

/** Set access tokens here - see: **/
$settings = array(
	'oauth_access_token' 		=> "YOUR_OAUTH_ACCESS_TOKEN",
	'oauth_access_token_secret' => "YOUR_OAUTH_ACCESS_TOKEN_SECRET",
	'consumer_key' 				=> "YOUR_CONSUMER_KEY",
	'consumer_secret' 			=> "YOUR_CONSUMER_SECRET"

$ta_url = '';
$getfield = '?screen_name=SwatantraKumar'; //'?screen_name=REPLACE_ME';
$requestMethod = 'GET';
$twitter = new TwitterAPIExchange( $settings );
$follow_count = $twitter->setGetfield( $getfield )
						->buildOauth( $ta_url, $requestMethod )
$data = json_decode( $follow_count, true );
$followers_count = $data[0]['user']['followers_count'];
echo $followers_count;

Parsing the XML

$xml = new SimpleXMLElement( urlencode( strip_tags( '' ) ), null, true );
echo "Follower count: ".$xml->followers_count;
'Coz sharing is caring
Games numbers PHP

Pyramid of stars in PHP

Write a program to generate pyramid of stars.

This is the most commonly asked question to beginners. Though this seems to be very complex during my school days, but not.

Program to generate/draw pyramid of stars/asterisks in php

echo '<pre>';
$horizontal = 10;
$vertical = 10;
while ($vertical--)
    echo str_repeat(' ', $vertical) . str_repeat('* ', $horizontal - $vertical) . "\n";
echo '</pre>';
'Coz sharing is caring