title: Select element from json dynamically
body: <p>I have a an associative array in php that i parse to get json from it (json_encode) then i store the result in a javascript var</p>
  
  <pre><code>var myArray = &lt;?php print json_encode($phpArray); ?&gt;;
  </code></pre>
  
  <p>Now whene the user hit a button i should choose another element from the array dynamically, for example, i chose a random first element :</p>
  
  <pre><code>var an_element = myArray.a2.link;
  </code></pre>
  
  <p>-'a2' is an array in the main array</p>
  
  <p>-'link' is an element in the a2 array.</p>
  
  <p>So now whene the user hit my button, i want to choose a random  other array id (for example a5, a9, etc.)
  I tried this :</p>
  
  <pre><code>var randomnumber=Math.floor(Math.random()*101); // choose random number
  var newRandomArrayID= "a"+randomnumber;
  an_element = myArray.newRandomArrayID.link;
  </code></pre>
  
  <p>It doesn't works, it says  myArray.newRandomArrayID is undefined.
  Anyone can help?
  Thank you</p>