up vote 0 down vote favorite
share [fb]

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

link|improve this question

Please, look at theme_table(). For example this answer. – kalabro Sep 2 at 11:16
feedback

1 Answer

up vote 1 down vote accepted

If you have

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

then 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 expected by theme_table, so look there about the specifics. Especially you might want to replace 'Some Index:' with array('data' => 'Some Index:', 'header' => true) to indicate that this cell is a table header cell.

link|improve this answer
Thanks a lot Oswald for that prompt answer and sorry i haven t accepted it earlier i got really busy...Cheers – silkAdmin Sep 5 at 15:57
feedback

Your Answer

 
or
required, but never shown

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