RON_ron Posted November 17, 2010 Share Posted November 17, 2010 How can I ignore - when doing claculations? e.g. 150 - 50 = 100 150 - 225 = -75 // I WANT to display only 75 and ignore the - sign Quote Link to comment Share on other sites More sharing options...
doni49 Posted November 17, 2010 Share Posted November 17, 2010 I assume you meant that you only want to "ignore" the negative by just echoing 75. Assuming that's the case, then convert the negative number to a positive and echo that value: $val = 150 - 225; $val = abs($val); echo $val; The abs function converts a positive to a negative. See the following: www.php.net/abs Quote Link to comment Share on other sites More sharing options...
RON_ron Posted November 17, 2010 Author Share Posted November 17, 2010 Thanks doni49!!!!! Quote Link to comment Share on other sites More sharing options...
doni49 Posted November 17, 2010 Share Posted November 17, 2010 No prob. Glad to help. Quote Link to comment Share on other sites More sharing options...
RON_ron Posted November 17, 2010 Author Share Posted November 17, 2010 Cheers! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.