Re: Fwd: GD library for creating tables

From: Date: Sat, 13 Dec 2008 10:35:11 +0000
Subject: Re: Fwd: GD library for creating tables
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-284582@lists.php.net to get a copy of this message
On Sat, 2008-12-13 at 10:18 +0200, Osman Osman wrote: > Hello, > I'm looking for a library in PHP that will let me easily create tables > programmatically. It would be great if I can just specify information about > the rows/columns, what each cell should contain, etc, and the table would > get created automatically. I should be able to do anything I would be able > to do with normal HTML tables. Is there anything like that available? > > Thanks, > Osman $arr = array(array('celldata row 1, col1', 'celldata row 1, col2'), array('celldata row 2, col1', 'celldata row 2, col2')); <table> <tr> <th>heading1</th> <th>heading2</th> </tr> <?php foreach ($arr as &$row): ?> <tr> <?php foreach ($row as &$col): ?> <td><?php echo $col ?></td> <?php endforeach ?> </td> <?php endforeach ?> </table> Do you really need a library for that? I had thought about this too but couln't come up with a good solution to do this generically and being as flexible as this. All you have to do is copy/paste the html code and put some php inbetween if you have a designed table with css and all that jazz. Tim

« previous php.general (#284582) next »