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 Link to comment https://forums.phpfreaks.com/topic/218915-ignore-and/ 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 Link to comment https://forums.phpfreaks.com/topic/218915-ignore-and/#findComment-1135327 Share on other sites More sharing options...
RON_ron Posted November 17, 2010 Author Share Posted November 17, 2010 Thanks doni49!!!!! Link to comment https://forums.phpfreaks.com/topic/218915-ignore-and/#findComment-1135329 Share on other sites More sharing options...
doni49 Posted November 17, 2010 Share Posted November 17, 2010 No prob. Glad to help. Link to comment https://forums.phpfreaks.com/topic/218915-ignore-and/#findComment-1135330 Share on other sites More sharing options...
RON_ron Posted November 17, 2010 Author Share Posted November 17, 2010 Cheers! Link to comment https://forums.phpfreaks.com/topic/218915-ignore-and/#findComment-1135331 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.