<?php
function tijdTotGelijk ($x, $y, $x_groei, $y_groei)
{
if(($x > $y && $x_groei > $y_groei) || ($x > $y && $x_groei > $y_groei))
{
echo 'Grootste getal groeit harder dan kleine getal.';
return false;
}
elseif($x == $y)
{
echo 'Getallen zijn gelijk.';
return false;
}
else
{
// Zorg ervoor dat $a de grootste is
if($x > $y)
{
$a = $x;
$a_groei = $x_groei;
$b = $y;
$b_groei = $y_groei;
}
else
{
$a = $y;
$a_groei = $y_groei;
$b = $x;
$b_groei = $x_groei;
}
$verschil = $a - $b;
$verschil_groei = $b_groei - $a_groei;
$resultaat = $verschil / $verschil_groei;
return $resultaat;
}
}
function tijdTotGelijk2($x, $y, $x_groei, $y_groei)
{
return =
abs(($x -
$y) /
($x_groei -
$y_groei));
}
echo tijdTotGelijk
(50,
20,
3,
10);
// Geeft als resultaat: 4.28571428571
echo tijdTotGelijk2
(50,
20,
3,
10);
// Geeft als resultaat: 4.28571428571
?>