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' =>$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' => array('funky'), // Attribute for the COL element.
),
),
// COLGROUP with attributes and inner COL elements.
array(
'data' => array(
array(
'class' => array('funky'), // Attribute for the COL element.
),
),
'class' => 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' => 'table',
'#header' => $header,
'#rows' => $rows,
'#attributes' => $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' => 'table',
'#header' => $header,
'#rows' => $rows,
'#variables' => $my_vars,
);