echo "<input type=\"text\" size=3 name=\"{$item[\"name\"]}\"/>";
but following works fine
echo "<input type=\"text\" size=3 name=\"{$item['name']}\"/>";
As per my understanding \" really escape the "
You don't need to escape the quotes inside the {}. That's supposed to be quoted because it means the string index "name" for the PHP array $name. Without quotes (or escaped quotes), name is treated as a constant (which I'm assuming it isn't), and then you've got an extra pair of quotes which don't belong.
OTOH, this would also be correct:
echo "<input type=\"text\" size=\"3\" name=\"$item[name]\"/>";
(no quotes around name and no {} either)
see http://www.php.net/manual/en/language.types.string.php#language.types.string.parsing
re:comment
Any non-keyword without quotes or the $ sign is regarded as a constant (as you can define with the define function), thus "name" (with quotes) is a string, and name without quotes is a constant.
when written like this, however:
echo "{$item[name]}";
PHP will first look for a constant with the name name, then if it doesn't exist, it will use the string "name". However, it will (depending on your settings?) also issue a warning.
Why use " anyway? It turns PHPs special character parsing on, eats more processor time. It is better practice to use '.
This way you don't have to escape all HTML quotation marks so the script will be nicer, shorter and less processor will used for simple text processing, where you just join text with a variable.
echo '<input type="text" size=3 name="'.$item['name'].'"/>"';
$item["name"] is the complete name for the variable so you can not build the variable name when you are using some of the print functions.
In this case it is better to concatenate the strings instead of inserting the variable in an implicit way. e.g.
echo "<input type=\"text\" size=3 name=\"" . $item["name"] . "\"/>";
or something like
printf("<input type=\"text\" size=3 name=\"%s\"/>", $item["name"]);
//Parameters info at http://www.php.net/manual/es/function.sprintf.php
Think what about what it would like after escaping
echo "<input type=\"text\" size=3 name=\"{$item[\"name\"]}\"/>";
would become
<input type="text" size=3 name="{$item["name"]}"/>";
which you can see is wrong as the quotes after the name attribute would terminate at the second quote leaving the rest hanging