thefollower Posted July 21, 2008 Share Posted July 21, 2008 I was wondering what function is best to use for converting a negative number to positive? So $Var = -400 would become $Var = 400. Im guessing theres 2 ways it can be done, removing the first char... or perhaps theres a function designed to change negative to positive. What function would i use ? Link to comment https://forums.phpfreaks.com/topic/115884-solved-string-manipulation/ Share on other sites More sharing options...
Third_Degree Posted July 21, 2008 Share Posted July 21, 2008 ( $var * -1 ) Link to comment https://forums.phpfreaks.com/topic/115884-solved-string-manipulation/#findComment-595823 Share on other sites More sharing options...
Jabop Posted July 21, 2008 Share Posted July 21, 2008 http://us.php.net/abs Link to comment https://forums.phpfreaks.com/topic/115884-solved-string-manipulation/#findComment-595824 Share on other sites More sharing options...
marcus Posted July 21, 2008 Share Posted July 21, 2008 $var = -400; $pos = abs($var); get the absolute value Link to comment https://forums.phpfreaks.com/topic/115884-solved-string-manipulation/#findComment-595825 Share on other sites More sharing options...
thefollower Posted July 21, 2008 Author Share Posted July 21, 2008 Thank you Link to comment https://forums.phpfreaks.com/topic/115884-solved-string-manipulation/#findComment-595830 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.