Click to See Complete Forum and Search --> : Problem with arrays in forms


Anon
10-30-2000, 06:39 PM
I have a problem with arrays in forms on windows. I have a big script using this feature a lot, which I use on my UNIX server, just recently, i moved the script over to a demo NT server (to check that everything works on NT, because I am moving the entire site to NT). However, on NT, none of the Arrays from the forms give values in PHP.

I have made a little example, to make it easier to understand:

When this script(test.php) is called on NT, with the following "Get String :"test.php?a[b]=uu&a[c]=vv"

The script returns on NT: 0
, however on UNIX, 2

When the script returns 0 when called this way, means it doesn't read the array.


Can anybody please tell me what is going on. I have no clue.

Anon
10-31-2000, 07:20 AM
where do the b and c in a[b] and a[c] stand for?
should they be just a[]=uu&&a[]=vv?

Anon
10-31-2000, 11:00 AM
the b and the c are there so you can reffer to it as a["b"] and a["c"] in the script, but it would work fine without them.

Anon
11-01-2000, 04:03 AM
I'm afraid that by entering the array values like a[b]
on NT your data will be transmitted not as an array but as a collection of variables named "a[b]" and "a[c]" etc.

My theory about how PHP handles arrays is this: (if someone knows for sure please respond)
In an HTML form each input item has a name, and each item gets sent back to the server on submit.
If you define the same name for an item several times, they are all sent to the server.
Normally when you access the variables you only see the first or last occurence of that name. PHP has just found a neat way of looking for variable names that end in "[]" and puts all those values into an array. (one for each unique name).

So, if you don't name your array something like "a[]" PHP doesn't recognise it.

Anon
11-01-2000, 11:21 AM
I've tried with a[] and a[] and a[] too, but that doesn't work on NT either.