Name

version_compare

Synopsis

mixed version_compare(string one, string two[, string operator])

Compares two version strings and returns −1 if one is less than two, 0 if they are equal, and 1 if one is greater than two. The version strings are split into each numeric or string part, then compared as string_value < "dev" < "alpha" or "a" < "beta" or "b" < "rc" < numeric_value < "pl" or "p".

If operator is specified, the operator is used to make a comparison between the version strings, and the value of the comparison using that operator is returned. The possible operators are < or lt; <= or le; > or gt; >= or ge; ==, =, or eq; and !=, <>, and ne.

Get Programming PHP, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.