Reply to Re: Passing arrays through posts, gets, and cookies

Your name:

Reply:


Posted by Good Man on 05/17/07 20:32

Mike P2 <sumguyovrthar@gmail.com> wrote in news:1179433389.464406.302460
@q75g2000hsh.googlegroups.com:

> I used to use arrays in input data that will be turned into a
> superglobal more often, but now that I care more about xHTML validity,
> I don't. Validation checking websites (particularly the W3C validator)
> yell at me for having square brackets in a name or id attribute. I
> started going the simple way of just separating what would be the
> array name from what would be the subscript with an underscore and
> parsing that out with PHP later. Is there a better, valid way of doing
> this that will have PHP set up my multidimensional superglobals for me
> as it would with the square brackets?
>
> -Mike PII
>
>

Hi Mike

i think square brackets for the 'name' attribute is fully valid xhtml -
you just can't have the ID with square brackets.

My code for forms tends to look like:
<input type="checkbox" value="yep" name="myBox[1]" id="myBox1" /> box 1
<input type="checkbox" value="yep" name="myBox[2]" id="myBox2" /> box 2

etc....

When processing the form, you can still do...

foreach($myBox as $key=>$value) {

}

....to retrieve the appropriate key/value pairs.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация