On 18/05/2009 10.42, Peter Ford wrote:
Daniele Grillenzoni wrote:
I noticed that php's way to fill $_GET and $_POST is particularly
inefficient when it comes to handling multiple inputs with the same name.

This basically mean that every<select multiple>  in order to function
properly needs to have a name ending in '[]'.

Wouldn't it be easier to also make it so that any element that has more
than one value gets added to the GET/POST array as an array of strings
instead of a string with the last value?

I can see the comfort of having the brackets system to create groups of
inputs easily recognizable as such, while I can overlook the
impossibility of having an input literally named 'foobar[]', having to
add [] everytime there is a slight chance of two inputs with the same name.

This sounds flawed to me, as I could easily append '[]' to every input
name and have a huge range of possibilities unlocked by that.

This can't be right. Or can it?

Isn't it ironic that a post about multiple form inputs is posted four times?
That's not a good way to make friends here, Daniele...

I really don't understand your complaint - in general if your form has multiple
inputs with the same name, then you either meant to do that, (like a multiple
select, in which case there's not really a big deal to add the []),
or it's wrong and wouldn't work as expected anyway.

You could append [] to every input - that would be lovely, but it would hide the
possibility that you mistakenly gave two inputs the same name.

It's true that every so often I can't work out why something is not posting an
array to PHP when I expected it to, and a look back to the form to find I'd
missed a [] on the name is the answer.

As I like to say in other areas of life (especially to my children), "stop
whining and get on with it!" ( sorry :) )

I'm sorry, it was due to my antispam block, which in turn blocked the mailing list antispam check. Quite ironic indeed. Also I thought I canceled the other 3, apparently it's something that is only apparent.

My complaint is this: a I can have a select multiple with a normal name, which is allowed by every spec, but PHP requires me to use [] in order to properly retrieve the values.

I guess I would settle for a function or an alternative array to $_GET and $_POST that worked properly.

Creating a function to fix those things is actually not that hard, but calling it everytime you need to use those arrays creates a lot of overhead. So maybe a core, or a PECL extension is/would be the answer.

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to