PHP code example of rmtram / version-sort

1. Go to this page and download the library: Download rmtram/version-sort library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rmtram / version-sort example snippets



$versions = array('v1.0.1', '1.30.3', 'version1.0.99', '1.0.4');
$vs = new Rmtram\VersionSort\VersionSort($versions);

// trimming v1.0.1 => 1.0.1 | version1.0.99 => 1.0.99
$vs->trim();

var_dump($vs->asc());
// result => ['1.0.1', '1.0.4', '1.0.99', '1.30.3']

var_dump($vs->desc());
// result => ['1.30.3', '1.0.99', '1.0.4', '1.0.1']