Skip to content

Instantly share code, notes, and snippets.

@klhall1987
Last active November 11, 2015 16:34
Show Gist options
  • Save klhall1987/5b9df81d31ac31255878 to your computer and use it in GitHub Desktop.
Save klhall1987/5b9df81d31ac31255878 to your computer and use it in GitHub Desktop.
is_int example
<?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