How to add a colspan in a table header? I need to create a table that will have a header with 4 columns and then all the rows will have 5 columns, so I need to add a colspan in the header.

This is an example of what I trying to do:

// The table header.
$header = [
  $this-&gt;t('Name'),
  $this-&gt;t('Description'),
  $this-&gt;t('Weight'),
  $this-&gt;t('Package'),
];

// The table.
$form['modules'] = [
  '#type' =&gt; 'table',
  '#header' =&gt; $header,
  '#rows' =&gt; [[1, 2, 3, 4, 5]],
  '#sticky' =&gt; TRUE,
];


This code just give something like this:



But I trying to obtain something like this:



I tried the last example in Add a class to a Drupal table cell containing [&#39;data&#39;] but just give some errors. 

If you go to see the class Table you will see an example using the colspan in the '#wrapper_attributes' but it seems not works for the '#header'

I can obtain a similar output just adding an empty header column like this:

// The table header.
$header = [
  $this-&gt;t('Name'),
  $this-&gt;t('Description'),
  $this-&gt;t('Weight'),
  '',
  $this-&gt;t('Package'),
];


This will give something like this:



But I think that the correct way is adding the colspan property to the header.

Maybe I'm missing something or we just need to wait for Multi level (multirow) header for table FAPI element to use the colspan in the table header?
I just found the solution looking a bit in the Multi level (multirow) header for table FAPI element and doing some test.

This is the way that I found:

// The table header.
$header = [
  $this-&gt;t('Name'),
  $this-&gt;t('Description'),
  [
    'data' =&gt; $this-&gt;t('Weight'),
    'colspan' =&gt; 2,
  ],
  $this-&gt;t('Package'),
];

// The table.
$form['modules'] = [
  '#type' =&gt; 'table',
  '#header' =&gt; $header,
  '#rows' =&gt; [[1, 2, 3, 4, 5]],
  '#sticky' =&gt; TRUE,
];