Skip to content

Instantly share code, notes, and snippets.

@scofennell
Created January 10, 2017 06:00
Show Gist options
  • Save scofennell/166520c3e0beb59fae9ccd2f19a8da09 to your computer and use it in GitHub Desktop.
Save scofennell/166520c3e0beb59fae9ccd2f19a8da09 to your computer and use it in GitHub Desktop.
Compare two version numbers in php.
/**
* Determine if this asset needs to be updated.
*
* @return boolean Returns TRUE of the local version number
* is lower than the remote version number, else FALSE.
*/
function needs_update() {
$old_version = $this -> old_version;
$new_version = $this -> new_version;
$compare = version_compare( $old_version, $new_version );
if( $compare == -1 ) { return TRUE; }
return FALSE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment