Normally you should always use quotes around string literal array keys ($arr['key'] instead of $arr[key]), as you will get the undefined constant notice otherwise. There is an exception to that rule( :rolleyes: ) when using a array variable within a double-quoted string literal and not using the "complex notation" (i.e. the curly braces). I prefer to avoid using that no-quote option so as to keep consistent in my quoting of keys. Therefore any of the following should work (if I didn't make any typos):
print "<td><input type='text' value='".$b['TD']."' name='stat[".$a['USERID']."][TD]' size=2></td>";
print "<td><input type='text' value='{$b['TD']}' name='stat[{$a['USERID']}][TD]' size=2></td>";
sprintf(
"<td><input type='text' value='%s' name='stat[%s][TD]' size=2></td>",
$b['TD'],
$a['USERID']
);
Scroll down the manual page on arrays for the section titled "Why is $foo[bar] wrong?" for more information.