rascle Posted March 2, 2009 Share Posted March 2, 2009 I have a variable that sometimes can be a negative and sometimes a positive but i want to output it so it is always a positive. How do i do this. I tried using abs() but didnt get anywhere. Thanks Link to comment https://forums.phpfreaks.com/topic/147614-solved-positives-and-negatives/ Share on other sites More sharing options...
genericnumber1 Posted March 2, 2009 Share Posted March 2, 2009 abs() should work. Can you show us some code? Link to comment https://forums.phpfreaks.com/topic/147614-solved-positives-and-negatives/#findComment-774912 Share on other sites More sharing options...
rascle Posted March 2, 2009 Author Share Posted March 2, 2009 i dont quite know how to use abs() but this is what someone told me it should be: $logoutday = $logged[logoutday]; $currentday = date("d"); $days = $currentday - $logoutday; $days=abs($days); Thanks Link to comment https://forums.phpfreaks.com/topic/147614-solved-positives-and-negatives/#findComment-774913 Share on other sites More sharing options...
genericnumber1 Posted March 2, 2009 Share Posted March 2, 2009 That should work fine. Once you echo $days it should always be positive unless you change the value again before echoing. Link to comment https://forums.phpfreaks.com/topic/147614-solved-positives-and-negatives/#findComment-774919 Share on other sites More sharing options...
rascle Posted March 2, 2009 Author Share Posted March 2, 2009 Oh Ok Thanks! Link to comment https://forums.phpfreaks.com/topic/147614-solved-positives-and-negatives/#findComment-774923 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.