note 15820 added to function.is-int
| From: | zica at dreamwiz dot com | Date: | Thu, 04 Oct 2001 03:15:14 +0000 |
| Subject: | note 15820 added to function.is-int | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-18549@lists.php.net to get a copy of this message | ||
I`m using this function... ^o^
<?
/*
made by zica ^^v
*/
function isInt( $val ) {
$isInt = true;
for ($i=0 ; $i<strlen($val) ; $i++) {
$chr = ord(substr($val, $i, 1));
if(!($chr >= ord('0') && $chr <= ord('9'))) {
$isInt = false;
break;
}
}
return $isInt;
}
$a = 10;
$b = '10';
$c = '1a0';
echo isInt($a); //true
echo isInt($b); //true
echo isInt($c); //false
### usage ###
if(isInt($a) == true) echo "This is Integer";
else echo "This is not Integer";
?>
Is this useful? ^^;;
If there is bugs, plz mail to me. ^^
Bye yo~
--
http://www.php.net/manual/en/function.is-int.php
http://master.php.net/manage/user-notes.php?action=edit+15820
http://master.php.net/manage/user-notes.php?action=delete+15820
http://master.php.net/manage/user-notes.php?action=reject+15820