note 47694 added to function.is-numeric
| From: | admin at carichat dot net | Date: | Thu, 25 Nov 2004 13:09:24 +0000 |
| Subject: | note 47694 added to function.is-numeric | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-81014@lists.php.net to get a copy of this message | ||
This Post Responds To mdallaire at virtuelcom dot com.
If You Want To Check To See If A Variable Has Not Letters, PHP Has A Beautiful Built-In Feature
Which Allows You To Do So:
<?php
$myString = "0123456789z";
if(ctype_digit($myString))
{
echo "The String $myString Contains Only Numeric Chars.";
}
else
{
echo "The String $myString Does Not Contain Only Numeric Chars.";
}
//Outputs The String 0123456789z Does Not Contain Only Numeric Chars.
?>
The Full ctype Listing:
ctype_alnum
ctype_alpha
ctype_cntrl
ctype_digit
ctype_graph
ctype_lower
ctype_print
ctype_punct
ctype_space
ctype_upper
ctype_xdigit
----
Manual Page -- http://www.php.net/manual/en/function.is-numeric.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+47694
Delete -- http://master.php.net/manage/user-notes.php?action=delete+47694&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47694&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47694&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47694&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47694&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47694&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+47694&report=yes
Search -- http://master.php.net/manage/user-notes.php