Quoting Array Keys 
Array keys should be quoted if they are strings or variables, even if you know that the variable evaluates to an integer. Quoting should follow the same rules as defined for string quoting. Note that $var = $array[$key]; will cause a parse error if $key is not quoted and is a negative integer, and will cause a notice if $key is a string and is unquoted.
$a = $userinfo[12];
$b = $userinfo['username'];
$c = $userinfo["$field"];
Compound array keys should quote the outermost variable.
$a = $userinfo["$var[12]"];
$b = $userinfo["$var[username]"];
$c = $userinfo["$var[$field]"];
Compound arrays within strings should be avoided if possible by breaking out of the string with the dot operator, although if absolutely unavoidable, the {...} array syntax can be used.
$a = "Hello my name is $userinfo[12], how do you do?";
$b = "Hello my name is $userinfo[username], how do you do?";
$c = "Hello my name is $userinfo[$field], how do you do?";

$d = 'Hello my name is ' . $userinfo["$var[field]"] . ', how do you do?';
$e = "Hello my name is {$userinfo[$var[username]]}, how do you do?";
Copyright © 2024 MH Sub I, LLC dba vBulletin. All rights reserved. vBulletin® is a registered trademark of MH Sub I, LLC dba vBulletin.