PHP Negative Value to Positive Value

Author: Zeeshan Arshad     1287     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 multipotentialite web developer who also happens to know about growth hacking, blogging, closing, marketing, copywriting, spirituality, virtual reality and more. Zeeshan is a Freelancer Top Contributor, vWorker Top Coder and Udemy Premium Instructor.

Story  LinkedIn Profile  Courses  YouTube