Hi All,
I'm having trouble gettiing the syntax correct with my eval statement. In the code below, the eval code for test2 works correctly. However, test3 code produces a syntax error. What am I missing?
$ar = array("a" => "1", "b" => "2");
$v = "b";
//test2
$s = "\$ar['" . $v . "']";
echo("<br />test2: ");
eval("echo($s);"); //works. Displays: test2: 2
//test3
echo("<br />test3: ");
eval("echo(\"\$ar['\" . $v . \"']\");"); //error