title: send an array from php to javascript file
body: <p>I want to send an array that is being created on a php file to a javascript file.
  The codes that I have made are the below but I cannot make it work.</p>
  
  <p>sample.php</p>
  
  <pre><code>&lt;form action="new-game.php" method="post"&gt;
  &lt;?php $playerNames = array();
      for ($i=0; $i&lt;$_POST["playerNo"]; $i++) {
          echo "&lt;form name=\"input\" action=\"#\" method=\"POST\"&gt;Όνομα: &lt;input type=\"text\" name=\"playerName\" value=\"\"&gt;&lt;br/&gt;";
          $playerNames[$i] = $_REQUEST['playerName'];
      }
  ?&gt;
  
      &lt;/br&gt;&lt;/br&gt;
      &lt;input type="submit" value="Αποστολή" onclick='showNames(&lt;?php echo json_encode($playerNames); ?&gt;);' /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>And I don't know how I should use the $playerNames array on script.js file.</p>