theme variables in array
Since the second argument of theme() is an array, you are writing code for Drupal 7. In that case, theme('table') doesn't use any array item whose index is an integer. The only array indexes you should pass as second argument to theme('table') are the following:


header
rows
attributes
caption
colgroups
stricky
empty


Since you are using array('variables' =&gt;$my_vars) it could be you are trying to set attributes, but in that case the array should be an array of HTML attributes, or colgroups, and in that case the array should be similar to the following one.

$colgroup = array(
  // COLGROUP with one COL element.
  array(
    array(
      'class' =&gt; array('funky'), // Attribute for the COL element.
    ),
  ),
  // COLGROUP with attributes and inner COL elements.
  array(
    'data' =&gt; array(
      array(
        'class' =&gt; array('funky'), // Attribute for the COL element.
      ),
    ),
    'class' =&gt; array('jazzy'), // Attribute for the COLGROUP element.
  ),
);


If you are trying to set attributes, your code should set the $build variable as following.

$build['table'] = array(
  '#theme' =&gt; 'table',
  '#header' =&gt; $header,
  '#rows' =&gt; $rows,
  '#attributes' =&gt; $my_vars,
);


Replace '#attributes' with '#colgroups' to set colgroups.

In the case theme('table') accepted variables (which could be the case if a module overrodr the default implementation of the theme function), then the code should be similar to the following one.

$build['table'] = array(
  '#theme' =&gt; 'table',
  '#header' =&gt; $header,
  '#rows' =&gt; $rows,
  '#variables' =&gt; $my_vars,
);