Pass php two dimensional array to javascript and access the values
<p>I can pass an array to javascript from php using Json_encode like this</p>

<pre><code>initiate_database(json_encode($_SESSION["ONE_DIMENSION_ARRAY"]);
</code></pre>

<p>and access the same array easy like this</p>

<pre><code>function initiate_databse(database)
{
  var local_array = database;
  window.alert(local_array[0]);
}
</code></pre>

<p>This will give me the first value of the array, However my problem is when I want to access two dimension array, I cannot access any value even the first one but when I run an alert on variable. It displays [[object Object],[object Object]]</p>

<p>How do I access this values I have tried the following</p>

<pre><code>window_alert(local_array[0][0])
window_alert(local_array[0]["name"])
</code></pre>

<p>With no luck, Please help.</p>

<p>Edit</p>

<p>Two dimension array seemed a better choice of description</p>

<p>I have a class which I created</p>

<pre><code>class test_class
{
 protected $name;
 protected $surname;
}
</code></pre>

<p>I then put values in an array as follows</p>

<pre><code>example test_class[] = array();
This is just an example to show what I do with the class.
</code></pre>

<p>I then transfer the array via json_encode to javascript, the problem is getting the variables of the class.</p>

<p>I get undefined when I try getting the value of $name in javascript as follows</p>

<pre><code>local_array[0]["name"]     gives "undefined"
local_array[0][0]          gives "undefined"
local_array[0]             gives me [object Obejct]
local_array                gives me [[obeject Object],[],[]]
</code></pre>

<p>I think I have given all the info I can</p>
