-3

I'm using Avada theme for wordpress, i update the version, but now i'm facing with this issue, count(): Parameter must be an array or an object that implements Countable, this is the code of the file:

    $middle_logo_menu_top_level_elements = 0;
    foreach ( $middle_logo_menu_elements as $menu_element ) {
        if ( null === $menu_element->menu_item_parent ) {
                $menu_element->menu_item_parent = '0';
        }
        if ( '0' === $menu_element->menu_item_parent ) {
                $middle_logo_menu_top_level_elements++;
        }
    }

    if ( $is_search_icon_enabled ) {
        $middle_logo_menu_top_level_elements++;
    }
    if ( $is_cart_icon_enabled ) {
        $middle_logo_menu_top_level_elements++;
    }
    //Here i got the problem
    $top_level_menu_items_count = count( $middle_logo_menu_top_level_elements);
    if ( 0 === $top_level_menu_items_count ) {
         $this->middle_logo_menu_break_point = $middle_logo_menu_top_level_elements / 2;
    } else {...

I don't know for what was this code before and don't know how to resolve it.

El0din
  • 3,208
  • 3
  • 20
  • 31
  • 1
    @El0din count() is meant for counting the number of elements in an array. Why would you want to count an integer? It's just a value. – EvE Sep 10 '18 at 00:12
  • 2
    I'm voting to close this question as off-topic because the answer is obvious if you were to read the manual for the `count()` function. Or the error message you are showing us – RiggsFolly Sep 10 '18 at 00:16
  • It may be useful if you explain what you are trying to do! – RiggsFolly Sep 10 '18 at 00:18
  • 2
    You updated the theme version or PHP version? If PHP the behavior is documented here, http://www.php.net/manual/en/migration72.incompatible.php `An E_WARNING will now be emitted when attempting to count() non-countable types (this includes the sizeof() alias function).` – user3783243 Sep 10 '18 at 00:27
  • yes, i updated the php version – El0din Sep 10 '18 at 00:29
  • @user3783243 you were the only one who help me, thanks a lot, i finally resolved – El0din Sep 10 '18 at 00:32
  • If that's not your code, you should contact the maintainers and alert them to the problem. – Phil Sep 10 '18 at 00:32
  • 1
    i did, but needed a fast answer – El0din Sep 10 '18 at 00:35

1 Answers1

1

The count function counts the number of elements in an array. e.g:

$my_array = [ 0, 2, 3, 4 ];

// produces 4
echo count($my_array);

What are you trying to do?

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
dustytrash
  • 1,568
  • 1
  • 10
  • 17