Skip to content

Instantly share code, notes, and snippets.

@gibbs
Created April 10, 2013 12:46
Show Gist options
  • Save gibbs/5354298 to your computer and use it in GitHub Desktop.
Save gibbs/5354298 to your computer and use it in GitHub Desktop.
Get latest Drupal version
<?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