note 79634 added to function.is-float
| From: | nicholas at blasgen dot com | Date: | Thu, 06 Dec 2007 06:38:45 +0000 |
| Subject: | note 79634 added to function.is-float | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-132876@lists.php.net to get a copy of this message | ||
Your function thinks my address is a floating point number. So it's not perfect. Really what
I want is a function that allows ctype_digit() to fail once, but only once, when it hits a period.
function better_float_check($float) {
$periods=0;
$split = split('', $float);
foreach ($split as $s) {
if (!ctype_digit($s)) {
if ($s!='.') return false;
else $periods++;
}
}
if ($periods==1)
return true; // all digits and only 1 decimal
else
return false; // more than one decimal
}
----
Server IP: 208.69.120.35
Probable Submitter: 71.116.64.139
----
Manual Page -- http://www.php.net/manual/en/function.is-float.php
Edit -- https://master.php.net/note/edit/79634
Del: integrated -- https://master.php.net/note/delete/79634/integrated
Del: useless -- https://master.php.net/note/delete/79634/useless
Del: bad code -- https://master.php.net/note/delete/79634/bad+code
Del: spam -- https://master.php.net/note/delete/79634/spam
Del: non-english -- https://master.php.net/note/delete/79634/non-english
Del: in docs -- https://master.php.net/note/delete/79634/in+docs
Del: other reasons-- https://master.php.net/note/delete/79634
Reject -- https://master.php.net/note/reject/79634
Search -- https://master.php.net/manage/user-notes.php