Arrays in PHP treat integer and string integers synonymously. If you set $a['1'] = '1'
and access $a[1]
you will get '1'
.
This is because php juggled your string key to an integer before assigning it; the assigment was actually made to an integer key.
PHP also juggles in the process of accesssing too which means if you try to access [1]
with ['1']
it will work. Therefore
there is no real distinction between string integers and real integer, you can use them interchangably.
Remember that '1.0'
does not equal '1'
or 1
with strict comparison. This is true of array keys as well: you can have
both ['1.0']
and ['1']
and they would be different elements but not [1]
and ['1']
.