NYCPHP Meetup

NYPHP.org

[nycphp-talk] How to return a calculated result or zero

Cliff Hirsch cliff at pinestream.com
Tue Jan 31 17:45:32 EST 2006


This has been driving me nuts:
 
$result = ($some calculation > 0)
                   ? $some calculation
                    : 0;
 
Sure it works, but ugly, ugly, ugly...
 
I run across this situation so often that I figured there must be a
built-in function. Ceiling, floor, mean, cosine. std...my grade school
memory is long gone.
 
After one last search, I came across this, which is pretty close:
 
$result = max($some calculation, 0);
 
Happy day...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20060131/046d785e/attachment.html>


More information about the talk mailing list