Forum Moderators: coopster
<?php
function GCD($a, $b) {
while ($b != 0) {
$remainder = $a % $b;
$a = $b;
$b = $remainder;
}
return abs ($a);
}
?>
And then simply divide both sides with it:
<?php
$a = 2048;
$b = 1152;
$gcd = GCD($a, $b);
$a = $a/$gcd;
$b = $b/$gcd;
$ratio = $a . ":" . $b;
?>
Not very elegant at this moment, but it works :-)