Jump to content

Recommended Posts

theres more to the code but yes when i print month it comes back one

 

full code ":

function birthday($birthday){   
list($month,$day,$year) = explode("-", $birthday);  

$today = getdate();   
$age = $today['year']-$year;
   
if(($month=$today[mon] && $day > $today[mday])){   


$age--;
}

return $birthday . " " . $month . " " . $day . " " . $year . " " . $age;  
}

 

the $birthday . " " . $month . " " . $day . " " . $year . " " .  was just added so i can try to trouble shoot the code and what i have prints

3-23-1992 1 23 1992 14

whem i am 15

Link to comment
https://forums.phpfreaks.com/topic/67597-solved-explode/#findComment-339583
Share on other sites

first of all you need to make your array keys which are strings surrounded by quotes.

$today['mon'] not $today[mon]

 

Secondly, = is the assignment. == is equal to.

Change $month=$today[mon]  to :

$month==$today['mon']

 

And I think something is wrong with your time if it thinks today is January.

 

PS: Your age function has some other flaws. Why did you change it?

http://www.phpfreaks.com/forums/index.php/topic,157084.msg683302.html#msg683302

Link to comment
https://forums.phpfreaks.com/topic/67597-solved-explode/#findComment-339585
Share on other sites

dont you love when a f*cking = throws off an entire code.

 

function birthday($birthday){   
list($month,$day,$year) = explode("-", $birthday);  

$today = getdate();   
$age = $today['year']-$year;
   
if(($month==$today['mon'] && $day > $today['mday'])){   


$age--;
}

return $birthday . " " . $month . " " . $day . " " . $year . " " . $age;  
}

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/67597-solved-explode/#findComment-339587
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.