CancelImage Upload

How to convert minus into positive numbers in PHP

In order to convert negative numbers into positives in PHP one simple function is required:
$positive = abs($x);

The abbreviation abs stands for absolute values, and works like this:

<?php

echo "abs(-430): ".abs(-430)."<br><br>";

echo "abs(-14.5): ".abs(-14.5)."<br><br>";

echo "abs(14.5): ".abs(14.5)."<br><br>";

echo "abs(-1230): ".abs(-1230)."<br><br>";

?>

The results:

abs(-430): 430

abs(-14.5): 14.5

abs(14.5): 14.5

abs(-1230): 1230


Login
Want to leave a comment?

No problem. Just enter your email and password below.


register | home | reminder

myDesignTool Networking • www.mydesigntool.cominfo@mydesigntool.com