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 Link to comment https://forums.phpfreaks.com/topic/222323-trying-to-figure-something-out/ Share on other sites More sharing options...
Rifts Posted December 21, 2010 Share Posted December 21, 2010 are you referring the their version numbers? Link to comment https://forums.phpfreaks.com/topic/222323-trying-to-figure-something-out/#findComment-1150007 Share on other sites More sharing options...
desjardins2010 Posted December 21, 2010 Author Share Posted December 21, 2010 ya, exactly Link to comment https://forums.phpfreaks.com/topic/222323-trying-to-figure-something-out/#findComment-1150011 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. Link to comment https://forums.phpfreaks.com/topic/222323-trying-to-figure-something-out/#findComment-1150026 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. Link to comment https://forums.phpfreaks.com/topic/222323-trying-to-figure-something-out/#findComment-1150037 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 Link to comment https://forums.phpfreaks.com/topic/222323-trying-to-figure-something-out/#findComment-1150057 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? Link to comment https://forums.phpfreaks.com/topic/222323-trying-to-figure-something-out/#findComment-1150060 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 />"; Link to comment https://forums.phpfreaks.com/topic/222323-trying-to-figure-something-out/#findComment-1150061 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 Link to comment https://forums.phpfreaks.com/topic/222323-trying-to-figure-something-out/#findComment-1150062 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 Link to comment https://forums.phpfreaks.com/topic/222323-trying-to-figure-something-out/#findComment-1150073 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 Link to comment https://forums.phpfreaks.com/topic/222323-trying-to-figure-something-out/#findComment-1150078 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"; } Link to comment https://forums.phpfreaks.com/topic/222323-trying-to-figure-something-out/#findComment-1150081 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.