0

I have an unsupported addon for concrete5 which is showing this error wehen upating php 7.1 to 7.2

i have not much knowledge about php and ask if somebody have an easy soltion for the code below.

<?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

2
  • Just replace the count() with is_array() Commented Oct 13, 2019 at 11:36
  • thanks for the help, but unfortunately after this fix a lot of other errors appear. i am going to switch to another addon. one which is made for php 7.2 and obove. Commented Oct 13, 2019 at 18:21

1 Answer 1

0

You could try casting your $tags variable as an array. (Take a look here: PHP: Count a stdClass object).

count($tags) would be count((array)$tags)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.