FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » php+html mixup in displaying multidimensional array in html tables
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: php+html mixup in displaying multidimensional array in html tables [message #176852 is a reply to message #176850] Sat, 28 January 2012 23:02 Go to previous messageGo to previous message
Michael Fesser is currently offline  Michael Fesser
Messages: 215
Registered: September 2010
Karma:
Senior Member
.oO(Thomas 'PointedEars' Lahn)

> This is how you would write virtually unmaintainable, error-prone, slow code
> that very likely also produces invalid HTML after a few changes.
>
> Please don't.
>
> <table>
> <?php
> foreach ($arr as $line)
> {
> ?>
> <tr>
> <?php
> foreach ($line as $cell)
> {
> ?>
> <td><?php echo htmlspecialchars($cell); ?></td>

[...]

You call _that_ maintainable and readable? IBTD.

You jump in and out from PHP and even use two different indentation
styles. That's just plain ugly and error-prone, since you don't really
see which parts belong together and where a block starts and ends.

If you don't want to use many 'echo' or 'print' statements (even though
it would make perfect sense in situations like this), use some template
mechanism.

Micha

--
http://mfesser.de/blickwinkel
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Fast/Easy way to extract a column from multi-dimensional array?
Next Topic: Freelance PHP Developer
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 10 07:40:33 GMT 2024

Total time taken to generate the page: 0.05001 seconds