How to sort versioning info

前端 未结 3 1310
误落风尘
误落风尘 2020-12-30 01:39

What\'s the right way, to handle versioning indicators like 2.4 or 2.4.0.9 etc. to get the ability of sorting versions.

PHP says, that

3条回答
  •  囚心锁ツ
    2020-12-30 02:00

    PHP has a version_compare function. Use usort to sort it. Like following. :)

    $a = array('2.4','2.3.4','2.4.0.9');
    usort($a, 'version_compare');
    

提交回复
热议问题