0

I have an error this : Warning: count(): Parameter must be an array or an object that implements Countable

public static function setSection( $section, $section_data = array(), $additional_section_data = array() ) {
    if(count($additional_section_data) > 0 && !empty($additional_section_data)){
        $section_data['fields'] = array_merge($section_data['fields'], $additional_section_data);
    }

    self::$sections[ $section ] = $section_data;
}
jrswgtr
  • 2,287
  • 8
  • 23
  • 49
chtouk
  • 303
  • 4
  • 13
  • 1
    var_dump() both `$section_data['fields']` and `$additional_section_data` and see what you get. – nice_dev Aug 27 '19 at 13:58
  • `$additional_section_data` is probably not an array when you call this function. It will be an array if you omit the parameter but when you don't omit the parameter you need to ensure you pass a countable. – apokryfos Aug 27 '19 at 14:01

1 Answers1

-1

This issue means the variable $section_data isn't an array. Try to use gettype function to find out the type of the var, or var_dump to display it.

  • If you remove this you'll get an issue on the next line in the function array_merge. $additional_section_data isn't an array, an isn't empty. What you'll get in the result array?) – Roman Nahornyi Aug 27 '19 at 15:19