[英]Error php 7.1 -> 7.2 :count(): Parameter must be an array or an object that implements Countable in concrete5 addon
I have an unsupported addon for concrete5 which is showing this error wehen upating php 7.1 to 7.2我有一个不受支持的具体 5 插件,在将 php 7.1 升级到 7.2 时显示此错误
i have not much knowledge about php and ask if somebody have an easy soltion for the code below.我对 php 了解不多,并询问是否有人对以下代码有简单的解决方案。
<?php
$arr_tags = array();
foreach ($pages as $page) {
$tags = $page->getAttribute('tags');
if ($tags && count($tags)) {
foreach ($tags as $tag) {
$arr_tags[] = $tag;
}
}
}
$unique_tags = array_unique($arr_tags);
$keys = array_keys($unique_tags, '');
foreach ($keys as $k) {
unset($unique_tags[$k]);
}
?>
count(): Parameter must be an array or an object that implements Countable count():参数必须是一个数组或者一个实现了Countable的object
You could try casting your $tags variable as an array.您可以尝试将 $tags 变量转换为数组。 (Take a look here: PHP: Count a stdClass object ). (看看这里: PHP:计算一个标准类 object )。
count($tags) would be count((array)$tags)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.