note 94768 deleted from function.abs by bjori
| From: | bjori@php.net | Date: | Mon, 18 Jan 2010 19:17:55 +0000 |
| Subject: | note 94768 deleted from function.abs by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-165087@lists.php.net to get a copy of this message | ||
Note Submitter: Berenoguz at superonline dot com
----
Here is a simple function to make positives to negative and negatives to positive. This is function:
<?php
function turn($x)
{
$y = abs($x);
if ($y == $x)
return "-$y";
else
return "$y";
}
?>
You can use this code:
<?php
echo turn(-5) + turn(10);
?>
The output is:
-5
;
Because 5 + -10 = -10