Search code examples
phpversioningsemantics

PHP Convert Semantic Versioning String To Integer/Float


I have a string variable in PHP storing the current version of my application in semantic versioning format:

 $version = "0.2.6";

How can I convert this to an integer or float where I can do things compare versions using < and >.


Solution

  • There is a special version_compare() function in php