I used to believe I fully understood sessions... Apparently PHP does not
handles numeric indexes in $_SESSION, as far as I can see. The same yields
for both PHP 4 and 5. Suggestions or explanations to the following? I
thought $_SESSION was a super global array, but arrays would for sure allow
for numeric indices, right?
As an example, this works:
$id = "number" . 3;
$_SESSSION[$id]++;
$id = "number" . 5;
$_SESSSION[$id]++;
print_r($_SESSI ON); //as expected, two elements occur on screen
If the variable does not exist, it is set to 1, else it is increased (some
code is cut away)
This does, strangely, not work:
$id = 3;
$_SESSSION[$id]++;
$id = 5;
$_SESSSION[$id]++;
print_r($_SESSI ON); //not as expected, only last element, and this will
always be 1.
Regards,
Svend Andreas Horgen.
handles numeric indexes in $_SESSION, as far as I can see. The same yields
for both PHP 4 and 5. Suggestions or explanations to the following? I
thought $_SESSION was a super global array, but arrays would for sure allow
for numeric indices, right?
As an example, this works:
$id = "number" . 3;
$_SESSSION[$id]++;
$id = "number" . 5;
$_SESSSION[$id]++;
print_r($_SESSI ON); //as expected, two elements occur on screen
If the variable does not exist, it is set to 1, else it is increased (some
code is cut away)
This does, strangely, not work:
$id = 3;
$_SESSSION[$id]++;
$id = 5;
$_SESSSION[$id]++;
print_r($_SESSI ON); //not as expected, only last element, and this will
always be 1.
Regards,
Svend Andreas Horgen.
Comment