count(): Parameter must be an array or an object that implements Countable - 7-Views
count(): Parameter must be an array or an object that implements Countable
count() throws a warning since PHP 7.2 in case a scalar or non-countable object is passed. We rely on this behavior in many places so code needs to be adjusted.
More info
Here is my solution for this.
function count_array($aArr) {
if (is_array($aArr)) {
return count($aArr);
} else {
return 0;
}
}