PHP Negative Value to Positive Value

Author: Zeeshan Arshad     1187     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.

Was this topic helpful?

Subscribe YouTube Channel

Zeeshan Arshad is a self-taught and multi-dimensional person with extraordinary track record of success with international clients and students.

Feel free to contact him for your project, training purpose or guidance.