Reputation: 459
I'm using this code:
if (($height/$width) > 0.5 && ($height/$width) < 0.8) {
// do stuff
}
For a particular image, $height/$width
evaluates to 0.66543438077634
(1080/1623). And yet this appears to be evaluating as false. Can anyone suggest why?
Upvotes: 0
Views: 77
Reputation: 28763
Try it like
$div = (float)($height/$width);
if ( $div > 0.5 && $div < 0.8) {
// do stuff
}
Or you can use
$div = (float)($height)/(float)($width);
Upvotes: 0
Reputation: 1371
Propably You have some problem someware else because this code works fine:
<?
$height = 1080;
$width = 1623;
if (($height/$width) > 0.5 && ($height/$width) < 0.8) {
echo 'IT WORKS';
}
var_dump(($height/$width));
?>
Upvotes: 2