title: Inserting PHP array into Javascript array
body: <p>I have an array like this:</p>
  
  <pre><code>Array
  (
  [0] =&gt; Array
      (
          [id] =&gt; 9826
          [tag] =&gt; "php"
      )
  
  [1] =&gt; Array
      (
          [id] =&gt; 9680            
          [tag] =&gt; "perl"
      )
  
  )
  </code></pre>
  
  <p>I want to pass this to a javascript variable that looks like this:</p>
  
  <pre><code>var availableTags = [
          "ActionScript",
          "AppleScript",
          "Asp",
          "BASIC",
          "C",
          "C++",
          "Clojure",
          "COBOL",
          "ColdFusion",
          "Erlang",
          "Fortran",
          "Groovy",
          "Haskell",
          "Java",
          "JavaScript",
          "Lisp",
          "Perl",
          "PHP",
          "Python",
          "Ruby",
          "Scala",
          "Scheme"
      ];
  </code></pre>
  
  <p>I have gotten this far:</p>
  
  <pre><code>var availableTags = [
          &lt;?php
                          foreach($Tags as $tag){
                                echo $tag['tag'];
                          }
                      ?&gt;
      ];
  </code></pre>
  
  <p>the problem I have is adding the double quotes around each tag and inserting a comma after each apart from the last. </p>
  
  <p>I'm not sure of how to best do that?</p>