PHP is_countable() Function

❮ PHP Variable Handling Reference

Example

Check whether the contents of a variable is a countable value or not:

<?php
$a = "Hello";
echo "a is " . is_countable($a) . "<br>";

$b = array("red", "green", "blue");
echo "b is " . is_countable($b) . "<br>";

$c = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");
echo "c is " . is_countable($c) . "<br>";

$d = [1, 2, 3];
echo "d is " . is_countable($d) . "<br>";
?>
Try it Yourself »

Definition and Usage

The is_countable() function checks whether the contents of a variable is a countable value or not.

This function returns true (1) if the variable is countable, otherwise it returns false/nothing.


Syntax

is_countable(variable);

Parameter Values

Parameter Description
variable Required. Specifies the variable to check

Technical Details

Return Value: TRUE if variable is countable, FALSE otherwise
Return Type: Boolean
PHP Version: 7.3+

❮ PHP Variable Handling Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.