note 84515 deleted from function.abs by salathe
| From: | salathe@php.net | Date: | Mon, 21 Sep 2020 14:28:57 +0000 |
| Subject: | note 84515 deleted from function.abs by salathe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-215174@lists.php.net to get a copy of this message | ||
Note Submitter: Ister
----
[*EDIT* by danbrown AT php DOT net: Merged user's corrected code with previous post content.]
jeremys indicated one thing - there is no sgn function wich actually seems a bit strange for me. Of
course it is as simple as possible, but it is usefull and it is a standard math function needed
occasionally.
Well, I have solved this function in a bit different matter:
<?php
function sgn($liczba)
{
if($liczba>0)
$liczba=1;
else if($liczba<0)
$liczba=-1;
else if(!is_numeric($liczba))
$liczba=null;
else
$liczba=0;
return $liczba;
}
?>
The difference is that it returns null when the argument isn't a number at all.