Last active
November 11, 2015 16:34
-
-
Save klhall1987/5b9df81d31ac31255878 to your computer and use it in GitHub Desktop.
is_int example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$numbers = array( | |
12, | |
1551, | |
'21', | |
'5115', | |
'I am a string', | |
); | |
//Loop of the numbers arry | |
foreach( $numbers as $number ){ | |
//filter integers only, string numerics will not pass this check | |
if( is_int( $number )){ | |
echo $number . ' is integer.' . '</br>'; | |
//else output the following sting | |
} else { | |
echo $number . ' is not integer.' . '</br>'; | |
} | |
} | |
?> | |
****Output**** | |
12 is integer. | |
1551 is integer. | |
21 is not integer. | |
5115 is not integer. | |
I am a string is not integer. | |
************** |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment