The following is a summary of the PHP array numeric key names:
The length of the key can only be within the length of the int, and will appear overwritten after the int range.
When you access a value in the range of a key name of int, PHP forces the numeric key name to be converted to the INT value type
When the number key name is longer than 19 digits, it becomes 0
The string or numeric type is the same when the key name is normal length
$i = 126545165;
$arr [' 126545165 '] = ' abc ';
$arr [126545165] = ' UiO ';
Var_dump ($arr);
Echo '
';
Var_dump (Isset ($arr [$i]));
When the length exceeds the integral type, the key name is confused <喎?http: www.2cto.com="" kf="" ware="" vc="" "="" target="_blank" class="keylink"> vcd4kpha+phbyzsbjbgfzcz0= "Brush:java;" > $i = 12312312312312; $arr [' 1000000000147483649 '] = ' abc '; $arr [1000000000147483649] = ' UiO '; Var_dump ($arr); Echo '
'; Var_dump (Isset ($arr [$i]));
When the length exceeds 20 digits, the key name becomes 0
$i = 123123123123123123123123123123;
Var_dump ($i);
Echo '
';
$arr [123123123123123123123123123123] = ' abc ';
$arr [Strval (123123123123123123123123123123)] = ' abc ';
Var_dump ($arr);
Echo '
';
Var_dump (Isset ($arr [$i]));
Echo '
';
Var_dump (Isset ($arr [Strval ($i)]));
Echo '
';
Var_dump (Array_keys ($arr));
The variable is accessed directly as a key name, and the result is different
$i = 123123123123123;
Var_dump ($i);
Echo '
';
$arr [$i] = ' abc ';
$arr [Strval ($i)] = ' abc ';
Var_dump ($arr);
Echo '
';
Var_dump (Isset ($arr [$i]));
Echo '
';
Var_dump (Isset ($arr [Strval ($i)]));
Echo '
';
Var_dump (Array_keys ($arr));
From several of the above tests, see:
If the key name is a number and the range is within an int, the string or int does not affect access
If the length is greater than int, it is automatically converted to float, the conversion for access occurs in all sorts of confusion, even directly into 0, so it is best to convert to string type
$i = 123123123123123123123123123123;
$j = ' 123123123123123123123123123123 ';
$arr 1[strval ($i)] = ' abc ';
$arr 2[$j] = ' abc ';
Var_dump ($arr 1);
Echo '
';
Var_dump ($arr 2);
So in the dynamic operation of the PHP array, if it is not possible to determine whether the key name will appear number or length is greater than int, then unify the key name Strval into a string to operate the most secure