To take the absolute value of a number in PHP, you can use the built-in abs() function. Here's an example:
main.php71 chars4 lines
In this example, we first create a variable $number
and assign it the value of -5. We then use the abs()
function to take the absolute value of $number
and assign the result to a new variable $absNumber
. We then use echo
to output the value of $absNumber
, which in this case is 5.
gistlibby LogSnag