1

I am trying to render a simple PHP array witch isn't a drupal render array, basicly it s something like this:

array(
  array(
    'Some Index:',
    ' Some value',
  ),
  array(
    'Some Index:',
    'Some value',
  )
);

I would like to render it as an HTML table, is there any out of the box API to do that ?

Thank all for the help,

Cheers

1

1 Answer 1

5

Assume you have code similar to this:

$table_data = array(
  array( 'Some Index', 'Some value'),
  array( 'Some Index', 'Some value'),
);

In this case, just call theme('table', array('header' => array(), 'rows' => $table_data));.

This will call theme_table(), unless your theme overrides that particular theming function. Any override, however, should expect the array to be structured in the same way as described for theme_table(), so look there about the specifics. In particular, you might want to replace 'Some Index' with array('data' => 'Some Index', 'header' => TRUE) to indicate that this cell is a table header cell.

0

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.