Numeric indexes in $_SESSION ??

From: Svend Andreas Horgen (svendah_at_aitel.hist.no)
Date: 04/30/04


Date: Fri, 30 Apr 2004 16:10:08 +0200

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($_SESSION); //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($_SESSION); //not as expected, only last element, and this will
always be 1.

Regards,
Svend Andreas Horgen.