0

How to check if a version number is greater or lower than another version number. Is their any tiny library for this?

Example:

'1.1.2' > '1.1.10' // should return false
'1.1.10' > '1.1.9' // should return true
0

1 Answer 1

4

You can use PHP function version_compare (link).

Then you can check what value returned (part of official documentation):

By default, version_compare() returns -1 if the first version is lower than the second, 0 if they are equal, and 1 if the second is lower.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.