How to pass an array from module to template file? I have an array printing in module file. I want to theme that array data,so I am not getting how can I get that array data in template file. I don't want to create theme function and all. is there any inline solution to pass from module to template. My code is like below.

$data['listfiles'] = array(
    '#theme' =&gt; 'table',
    '#header' =&gt; $filesheader,
    '#rows' =&gt; $rows,
    '#empty' =&gt; t('No content available.'),
  );

  return $data; 


I want to pass $data variable to the template file, so that I can theme the data.Thanks in advance for any suggestions.
In form.

/**
 * Implements hook_theme().
 */
function YOURMODULE_theme() {
  $themes = array(
    'example' =&gt; array(
      'template' =&gt; 'templates/example',
      'arguments' =&gt; array('data' =&gt; NULL),
    ),
  );
  return $themes;
}


after this you can pass your data as


  return theme('example', array('data' => $data));


Refer this

And if want to use preprocess to alter data, see hook_preprocess_HOOK