Posted by NC on 09/17/05 01:43
chris wrote:
>
> I was looking through some PHP code and saw the below line of code
> and was wondering what it did -
>
> $w = ($tmp[0]>$maxw) ? $maxw : $tmp[0];
This is a shorter way to write:
if ($tmp[0]>$maxw) {
$w = $maxw;
} else {
$w = $tmp[0];
}
Can't help but note that there was an even neater way to get it done:
$w = min($tmp[0], $maxw);
Cheers,
NC
Navigation:
[Reply to this message]
|