« Return to Blog

PHP Negative Value to Positive Value

Author: Zeeshan Arshad     1303     09/09/2015

Estimated reading time: 0 minutes, 14 seconds

Converting a number from negative to positive is a pretty simple process using the absolute function abs():

$value = abs(-123); // = 123
$value = abs(123); // also = 123

Absolute returns a positive integer or float based. It only returns a positive value, you don't have to worry about what number is going in.