Javascript alert box using javascript variable and php array
<p>I am trying to print <code>johan</code> using javascript alert box with javascript variable and php array. But following code is not working.  </p>

<p>

<pre><code>$result['firstName']['lastName']='johan';
$data =  json_encode($result);

?&gt;
&lt;html&gt;
&lt;body onload='myfunction(&lt;?php echo $data; ?&gt;);'&gt;
&lt;script&gt;
function myfunction(data) 
{
  var fn = "firstName";
  alert(data.+fn+.lastName);
}
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
