Voting

: min(seven, six)?
(Example: nine)

The Note You're Voting On

nicolas dot giraud at actiane dot com
12 years ago
Just a shorter way to check if your variable is an int or a string containing a int without others digit than 0 to 9 :

<?php
$bool
= ( !is_int($value) ? (ctype_digit($value)) : true );

$value = 42; //true
$value = '42'; //true
$value = '1e9'; //false
$value = '0155'; //true
$value = 0155; //true
$value = 0xFF; //true while it's just the same as 255
$value = '0xFF'; //false
$value = 'a'; //false
$value = array(); //false
$value = array('5'); //false
$value = array(5); false
$value
= ''; //false
$value = NULL; //false

?>

Short & cool :)

<< Back to user notes page

To Top