Posted by gosha bine on 04/17/07 19:32
JamesG wrote:
>
> Thanks so much for correcting the silly mistake.
> I also hate nested elseifs but in this case it's the only way to do it
> I think-- I considered a switch statement but that isn't useful in
> this instance.
>
>
>
you actually don't need else's here, because you return in every branch.
Just use ifs:
if($ts < 60)
return $ts . " seconds ago";
if($ts < (60 * 60))
return intval($ts / 60) . " minutes ago";
etc
--
gosha bine
extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok
Navigation:
[Reply to this message]
|