简体   繁体   English

错误 php 7.1 -> 7.2:count(): Parameter must be an array or an object that implement Countable in concrete5 addon

[英]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.

相关问题 PHP 7.2: count(): 参数必须是数组或实现Countable的object - PHP 7.2: count(): Parameter must be an array or an object that implements Countable PHP 7.2 警告count():参数必须是数组或实现Countable的object - PHP 7.2 Warning count(): Parameter must be an array or an object that implements Countable count():参数必须是一个数组或一个 object 实现 php 中的可计数错误 - count(): Parameter must be an array or an object that implements Countable error in php PHP 错误 - 警告:count():参数必须是实现 Countable 的数组或对象 - PHP Error - Warning: count(): Parameter must be an array or an object that implements Countable PHP错误:警告:count():参数必须是实现Countable的数组或对象 - PHP error: Warning: count(): Parameter must be an array or an object that implements Countable 如何修复 PHP 7.2 警告:count():参数必须是一个数组或实现 Countable in errors.php 的数组或 object? - How to fix PHP 7.2 Warning: count(): Parameter must be an array or an object that implements Countable in errors.php? yii2 gridview count():参数必须是实现Countable php 7.2的数组或对象 - yii2 gridview count(): Parameter must be an array or an object that implements Countable php 7.2 PHP警告:count():参数必须是数组或实现Countable的对象? - PHP Warning: count(): Parameter must be an array or an object that implements Countable? PHP count():参数必须是一个数组或一个实现了Countable的对象 - PHP count(): Parameter must be an array or an object that implements Countable PHP:count():参数必须是数组或者实现了Countable的对象 - PHP: count(): Parameter must be an array or an object that implements Countable
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM