Is there any difference between integer index and string index of PHP arrays (except of course the fact that the latter is called associative array
)?
So for example, what are the differences between the following two arrays:
$intIndex[5] = "Hello";
$intIndex[6] = "World";
$intIndex[7] = "!";
And
$strIndex['5'] = "Hello";
$strIndex['6'] = "World";
$strIndex['7'] = "!";
In the first case, what happens to $intIndex[0]
to $intIndex[4]
?
Undefined index 0/4
PHP warning. – TiMESPLiNTER 43 mins ago0
or4
. It's an undefined index in this array. So if you use$intIndex[0]
you will run into anUndefined index
PHP warning. – TiMESPLiNTER 41 mins ago$intIndex[0] = 'foo';
will allocate memory for this specific index. – TiMESPLiNTER 25 mins ago