note 31503 deleted from function.version-compare by derick

From: Date: Sun, 01 Jun 2003 14:35:27 +0000
Subject: note 31503 deleted from function.version-compare by derick
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-49537@lists.php.net to get a copy of this message
Note Submitter: Ingo W. ---- a short and easy to use version may be like: /** * return true if minimum version requirement is met */ function phpminver ($minVer) { $curVer=explode(".", phpversion()); $minVer=explode(".", $minVer); //check if no of elements in $curVer and $minVer is correct if ( count ($minVer) != 3 || count ($curVer) != 3 ) { //some unknown versionstring return FALSE; } $i=0; //compare from left to right foreach ( $curVer as $curVerSub ) { if ( $curVerSub > $minVer[$i] ) { //current version is better return TRUE; } if ( $curVerSub < $minVer[$i] ) { //current version is worse return FALSE; } if ( $curVerSub == $minVer[$i] && $i == 2 ) { //versions are exactly the same return TRUE; } $i++; } //this should never be reached - but just to be save return FALSE; }

« previous php.notes (#49537) next »