Created
April 10, 2013 12:46
-
-
Save gibbs/5354298 to your computer and use it in GitHub Desktop.
Get latest Drupal version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Get Drupal latest version | |
*/ | |
$latest = NULL; | |
$url = 'http://updates.drupal.org/release-history/drupal/7.x'; | |
$context = stream_context_create(array( | |
'http' => array( | |
'method' => 'GET', | |
'timeout' => 10, | |
), | |
)); | |
$data = file_get_contents($url, FALSE, $context); | |
if($data) | |
$feed = simplexml_load_string($data); | |
if($feed && $feed instanceof SimpleXMLElement) { | |
// Check the property exists and assign | |
if( isset($feed->releases->release[0]->version) ) { | |
$latest = $feed->releases->release[0]->version; | |
echo $latest; | |
// return $latest; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment