Looking for a PEAR HTML_Table replacement

I have some problems using PEAR HTML_Table (severe error, the error appears to be open).

I want to find a standard way to generate HTML output that creates a table from associative arrays (where the key should be in column # 1, the value in column # 2, if nested, it should make a subtable, if possible, if not, just drop under -key.

Also, if possible, it would be nice to have formatting, like changing lines and hovering over lines, but that is obviously an option.

Significantly: I would like to have "plain PHP code", not an extension that requires a DLL due to update restrictions on the PHP server I'm using.

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

+3


source to share


2 answers


There are many classes for generating tables.

https://github.com/search?l=PHP&q=datagrid&type=Repositories



Just to name a few:

0


source


I have your back, buddy. I just updated naomik / htmlgen with 2.x . 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 (spaces not included in the 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>

      

0


source







All Articles