there have two value, $a and $b. I need make a judge, $a is not 3 times as bigger as b or $b is not 3 times as bigger as $a, echo $a.' and '.$b; else not.
for explain:
if $a = 5, $b=1 so $b*3 = 3, $b*3 < $a, then echo ‘nothing’;
if $a = 5, $b=2 so $b*3 = 6, $b*3 > $a, then echo $a.' and '.$b;//5 and 6
if $b = 5, $a=1 so $a*3 = 3, $a*3 < $b, then echo ‘nothing’;
if $b = 5, $a=2 so $a*3 = 6, $a*3 > $b, then echo $a.' and '.$b;//6 and 5
one of my code:
$a='5';
$b='1';
if ((!($a>=($b*3))) or (!($b>=($a*3)))){
echo $a.' and '.$b; //this may be echo 'nothing'
}else{
echo 'nothing';
}
From your examples, you seem to want to print ‘nothing’ if the values are very different, but if the values are close (within a factor of 3) then you print the values.
You just need to fix the logic in your test line:
if ($a < $b * 3 && $b < $a * 3) {