Menu Home

is_countable

osbo.com | PHP | Functions | is_countable

Verify that the contents of a variable is a countable value

Syntax

is_countable ( mixed $var ) : bool

Parameters

var

The value to check

Return

Returns TRUE if var is countable, FALSE otherwise.

Examples

1

<?

$var = array();

$return = is_countable($var);

echo $return;

?>
1

2

<?

$var = array(0, 1);

$return = is_countable($var);

echo $return;

?>
1

3

<?

$var = new ArrayIterator();

$return = is_countable($var);

echo $return;

?>
1

4

<?

$array = array(0, 1);

$var = new ArrayIterator($array);

$return = is_countable($var);

echo $return;

?>
1

PHP