desjardins2010 Posted December 21, 2010 Share Posted December 21, 2010 guys is it possible to somehow compare something like these two together and make a choice depending on the out come SystemKeyv1.0 and PasswordCrackerv2.0 PasswordCrackerv2.0 is grater than SystemKeyv1.0 can these be compared somehow? thank for advise guys; Cheers Quote Link to comment Share on other sites More sharing options...
Rifts Posted December 21, 2010 Share Posted December 21, 2010 are you referring the their version numbers? Quote Link to comment Share on other sites More sharing options...
desjardins2010 Posted December 21, 2010 Author Share Posted December 21, 2010 ya, exactly Quote Link to comment Share on other sites More sharing options...
desjardins2010 Posted December 21, 2010 Author Share Posted December 21, 2010 if we can get some brainstorming going on here I'm sure we can figure something out. Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted December 21, 2010 Share Posted December 21, 2010 if the version number will always be in the form x.y, where x and y are a single integer, 0-9, you could just take the last three characters of each string and compare them directly. Quote Link to comment Share on other sites More sharing options...
Rifts Posted December 21, 2010 Share Posted December 21, 2010 or if you know that the only numbers in the name will be the version number you can preg match them then compare Quote Link to comment Share on other sites More sharing options...
desjardins2010 Posted December 21, 2010 Author Share Posted December 21, 2010 using the statement from BlueSky can you give me a snipplet of doing this? how can I select the last 3 char of the string? Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted December 21, 2010 Share Posted December 21, 2010 $thisvar = 'hello world'; $last_three = substr($thisvar, -3); echo "last_three: $last_three <br />"; Quote Link to comment Share on other sites More sharing options...
desjardins2010 Posted December 21, 2010 Author Share Posted December 21, 2010 substr thanks man... then just compare them two values.. perfect ! appreciate it Quote Link to comment Share on other sites More sharing options...
desjardins2010 Posted December 21, 2010 Author Share Posted December 21, 2010 BlueSky I was trying to message you but for some reaso it wasn't working.. after I get the two last three digits? how can I compare them if ($lastthree > $otherthree)? the passwordcrackerv1.0 is a txt field in the database? does that not make what I'm comparing non numeric Quote Link to comment Share on other sites More sharing options...
desjardins2010 Posted December 21, 2010 Author Share Posted December 21, 2010 for anyone else who might be looking at this and have a solution please do using this it spits out the 2.0 and 1.0 how can I say if one is higher or equal to the other do something else do something else.. problem I see is that when I rip these off the end of the program name thats in the db as a text field.. <?php $passwordcracker = "PasswordcrackerV2.0"; $systemkey = "1.0"; $lastthree = substr($passwordcracker, -3); echo $lastthree."<br />"; echo $systemkey; ?> any ideas thanks Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted December 21, 2010 Share Posted December 21, 2010 doesn't matter if they are text. '2.3' is still greater than '1.0' $var1 = '1.0'; $var2 = '2.3'; if ($var1 > $var2) { echo "var1 is a higher value"; } else if ($var1 < $var2) { echo "var2 is a higher value"; } else { echo "both vars are the same"; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.