| ||||||
|
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
|