Jeffrey L. Roberts Jeffrey L. Roberts - 11 months ago 38
PHP Question

PHP Functions to Increment Classic Software Version Numbers?

I am looking for PHP functions that can increment classic software version numbers...



$a_version_number = '3.1.2';

$c = version_increment($a_version_number);
echo 'Next Version: ' . $c . "\n";

Any ideas on where I can find functions that would do what I am looking to do?


Here is a single function that will do both. If the second argument is a positive number, it will increment. If it's a negative number, it will decrement:

function version_update($i, $inc_dec){
    $a = explode('.', $i);
    if($inc_dec > 0){
    } elseif ($inc_dec < 0){
    return implode('.', $a); 

$b = version_update($a_version_number, -1);
echo 'Previous Version: ' . $b . "\n";

$c = version_update($a_version_number, 1);
echo 'Next Version: ' . $c . "\n";