$arr = eval(\"array(\'foo\'=>\'bar\');\"); // returns null var_dump($arr);
Can someone please explain why did I get null instead of an array?>
First of all, eval is highly discouraged as explained in the manual.
eval
Also, you should be doing something like $arr = eval("return array('foo'=>'bar');"); ie. initialising $arr with the eval function. See it in action here
$arr = eval("return array('foo'=>'bar');");
$arr