Jump to content

[SOLVED] explode


sstangle73

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.