- explode: documentation ( source)
- printf: documentation ( source)
<?php
function new_new_version_compare($a, $b){
return explode(".", $a) <=> explode(".", $b);
}
$versions = ["2.5.1", "2.5.2", "2.5.5", "2.5.11"];
$versus = "2.5.2";
foreach ($versions as $version) {
printf("%s -v- %s = %s\n", $version, $versus, new_new_version_compare($version, $versus));
}