gnope php gtk gui gnope.org  

version_compare

 
Post new topic   Reply to topic    gnope.org Forum Index -> PHP GTK2 Beginners
View previous topic :: View next topic  
Author Message
leon_pegg



Joined: 12 Jun 2006
Posts: 113
Location: hemel / UK

PostPosted: Fri Aug 04, 2006 5:23 pm    Post subject: version_compare Reply with quote

i got board today and wrote this.
i know its not of much use but here i a function to compare versions that supports geek numbers 1-9 and RC=10 PL=11 DEV=0

Code:

function greek_fix($text){
   $text = str_replace(array("_", "-", "+"),".",$text);
   $ver_split = explode('.', $text);
   //print_r($ver_split);
   foreach ($ver_split as $ver_key => $ver_value){
      $ver_split[$ver_key] = greek_to_number($ver_value);
   }
   return implode(".", $ver_split);
}

function greek_to_number($text){
   $letter = array("dev","alpha","beta","digamma","delta","epsilon","gamma","zeta","theta","eta","a","b","g","d","e","ß","û","z","h","q","rc","pl");
   $number = array("0","1","2","6","4","5","3","7","9","8","1","2","3","4","5","6","6","7","8","9","10","11");
      foreach ($letter as $key => $value){
         $text = str_replace($value,$number[$key],strtolower($text));
      }
      return $text;
}   

function version_cmp($ver1,$ver2,$oper=null){
   $ver1 = greek_fix($ver1);
   $ver2 = greek_fix($ver2);
   return version_compare($ver1,$ver2);
}


someone might find this usefull
Back to top
Display posts from previous:   
Post new topic   Reply to topic    gnope.org Forum Index -> PHP GTK2 Beginners All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Templates enhanced by DigiWiki. Hosting by Tradebit.