update page now
Longhorn PHP 2026 - Call For Papers

Voting

: max(three, nine)?
(Example: nine)

The Note You're Voting On

mindplay.dk
13 years ago
This little script can perhaps help you understand version comparison a little better - the output is displayed in the comment at the top. Tweak the list of versions if you need more examples...

<?php

#      1 lt 1.0
#    1.0 lt 1.01
#   1.01 eq 1.1
#    1.1 lt 1.10
#   1.10 gt 1.10b
#  1.10b lt 1.10.0

header('Content-type: text/plain');

$versions = array(
  '1',
  '1.0',
  '1.01',
  '1.1',
  '1.10',
  '1.10b',
  '1.10.0',
);

$comps = array(
 -1 => 'lt',
  0 => 'eq',
  1 => 'gt'
);

foreach ($versions as $version) {
  if (isset($last)) {
    $comp = version_compare($last, $version);
    echo str_pad($last,8,' ',STR_PAD_LEFT) . " {$comps[$comp]} {$version}\n";
  }
  $last = $version;
}

?>

<< Back to user notes page

To Top