getAge() - Classical

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
harrisonad
Forum Contributor
Posts: 288
Joined: Fri Oct 15, 2004 4:58 am
Location: Philippines
Contact:

getAge() - Classical

Post by harrisonad »

Hi,
I know this is funny but once again I want to relive this issue. I want to reduce it to one line.
My attempt goes like...

Code: Select all

$age = (date("Y") - $bday_year) - ($bday_month >= date("m") ? ($bday_day >= date("d") ? 0 : 1) : 1);
You are free to give your opinion on that.
Last edited by harrisonad on Tue Aug 30, 2005 9:45 pm, edited 3 times in total.
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

harrisonad wrote:I want to reduce it to one line.
But It is one line :?
Maybe more explanation will be clearer...
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

Post by pleigh »

elimate some spaces, hehe.. :wink:
Post Reply