在搜索PEAR HTML_Table替换

I have some trouble using PEAR HTML_Table (Strict error, bug seems still open).

I want to find a standard way to create HTML output that produces a table from associative arrays (where the key shall be in col#1, value in col#2 if nested it shall make a sub-table, if possible, if not, just indent the sub-key.

Also, if possible, would be nice to have formatting means like alteranting rows and hover of lines, but that's obviously an option.

Significant: I would like to have "plain php code" rather than an extension that requires a dll due to update restrictions on the PHP server I use.

Any hints / tips for me to do this without crunching my own code?

I've got your back, mate. I just updated naomik/htmlgen with a 2.x release. See other code in the example directory.

use function htmlgen\html as h;
use function htmlgen\map;

$beeData = [
  'pop' => 'yup',
  'candy' => 'sometimes',
  'flowers' => 'so much',
  'water' => 'not really',
  'sand' => 'indifferent',
  'donuts' => 'most definitely'
];

echo h('table',
  h('thead',
    h('tr',
      h('td', 'item'),
      h('td', 'do bees like it?')
    )
  ),
  h('tbody',
    map($beeData, function($value, $key) { return
      h('tr',
        h('td', $key),
        h('td', $value)
      );
    })
  )
);

Output (whitespace not included in actual output)

<table>
  <thead>
    <tr>
      <td>item</td>
      <td>do bees like it?</td>
    </tr>
  </thead>
  <tbody>
   <tr>
     <td>pop</td>
     <td>yup</td>
   </tr>
   <tr>
     <td>candy</td>
     <td>sometimes</td>
   </tr>
   <tr>
     <td>flowers</td>
     <td>so much</td>
   </tr>
   <tr>
     <td>water</td>
     <td>not really</td>
   </tr>
   <tr>
     <td>sand</td>
     <td>indifferent</td>
   </tr>
   <tr>
     <td>donuts</td>
     <td>most definitely</td>
   </tr>
 </tbody>
</table>