graham23s Posted November 10, 2007 Share Posted November 10, 2007 Hi GUys, im working out a users age, by deducting the year they were born from this year 2007 so i'm born on 1979, todays year is 2007 2007 - 1979 leaves 28 but the code shows as -28 instead of just 28, i tried a str_replace but no joy ## Year calculation $profileyear = $yearborn - $thisyear; ## Get rid of the - sign str_replace("-"," ", $profileyear); can anyone tell me what i did wrong? thanks guys Graham Link to comment https://forums.phpfreaks.com/topic/76748-solved-calculation-problem/ Share on other sites More sharing options...
rajivgonsalves Posted November 10, 2007 Share Posted November 10, 2007 maybe you should try it the otherway round ## Year calculation $profileyear = $thisyear - $yearborn; Link to comment https://forums.phpfreaks.com/topic/76748-solved-calculation-problem/#findComment-388571 Share on other sites More sharing options...
rajivgonsalves Posted November 10, 2007 Share Posted November 10, 2007 as for why it did not work str_replace("-"," ", $profileyear); should be $profileyear = str_replace("-"," ", $profileyear); Link to comment https://forums.phpfreaks.com/topic/76748-solved-calculation-problem/#findComment-388572 Share on other sites More sharing options...
graham23s Posted November 10, 2007 Author Share Posted November 10, 2007 ahh brilliant, thanks mate:) Graham Link to comment https://forums.phpfreaks.com/topic/76748-solved-calculation-problem/#findComment-388574 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.