The Error

warning: array_keys() [function.array-keys]: The first argument should be an array in /home/vermontbiz/webapps/vermontbiz/modules/int_meta/int_meta_cck.module on line 39. warning: Invalid argument supplied for foreach() in /home/vermontbiz/webapps/vermontbiz/modules/int_meta/int_meta_cck.module on line 39.

The Code

function function int_meta_cck_int_meta($op, &$arg) {
  switch ($op) {
    case 'load': {
      if (!empty($arg->int_meta)) {
        $supported = int_meta_cck_supported($arg->type);
        foreach ($arg->int_meta as $key => $tag) {
          if (in_array($tag->field, $supported)) {
            $parts = explode('.', $tag->field);
            if (isset($arg->{$parts[0]})) {
             foreach ($arg->{$parts[0]} as $tmp) {
               $arg->int_meta[$key]->values[] = $tmp[$parts[1]];

    case 'fields': {
      return int_meta_cck_supported($arg);

function int_meta_cck_supported($arg) {
  $fields = array();
  if (!empty($arg)) {
    $type = content_types($arg);
    if (!empty($type)) {
      foreach ($type['fields'] as $name => $info) {

      //**Error below takes place in the line below but doesn't effect all content**

        foreach (array_keys($info['widget']['default_value'][0]) as $col) {
          $fields[] = $name . '.' . $col;
return $fields; }

My question is why does the line give an error to some content types but not others?

The two content types.

This content type works with the module

This content type doesn't work with the module

  • LINE 22 didn't make it into question Jul 5, 2011 at 18:11
  • Compare the field types of your content types. Do all that produce this error share a common field or field type? If yes, which one? Also sounds like something you should report as a bug for that int_meta module.
    – Berdir
    Jul 5, 2011 at 18:17
  • 1
    A side note: It seems that you have placed contributed/custom modules in the top level modules directory. You should not do that. Instead, place them in sites/all/modules.
    – Berdir
    Jul 5, 2011 at 18:50
  • Why is that? Could that be an issue?
    – Nick
    Jul 5, 2011 at 18:53
  • No, not for that issue. But modules/ is reserved for core modules. It will make upgrading to another major version unecessary complicated for example.
    – Berdir
    Jul 5, 2011 at 18:58

1 Answer 1


You're making an assumption and that is that


Will always be an array. My guess is that for some fields (depending on configuration) that $info['widget']['default_value'][0] will be either NULL, FALSE or a scalar value.

  • There are differences in the field types.
    – Nick
    Jul 5, 2011 at 18:29
  • Can I paste images in the comments?
    – Nick
    Jul 5, 2011 at 18:30
  • @Nick, no, but you can edit your original question and add them there.
    – Berdir
    Jul 5, 2011 at 18:41
  • Well I found a module that worked much better. Thanks @Berdir for all your help.
    – Nick
    Jul 5, 2011 at 19:21

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.