title: Using PHP in <script> tag?
body: <p>I'm trying to create an object in javascript with PHP. This is my script:</p>
  
  <pre><code>    &lt;script&gt;
          $(document).ready(function(){
              var genres = [
      &lt;?php
      $last = count($userGenres) - 1;
      $i = 0;
      foreach($userGenres as $a){
          $i++;
          echo '{"value":"'.$a['genre'].'", "name":"'.$a['name'].'"}';
          if($i &lt; $last){
              echo ',';
          }
      }
      ?&gt;
                          ];
     });
  &lt;/script&gt;
  </code></pre>
  
  <p>When I check the generated source, it creates a valid object, but the whole script in that tag doesn't work now. How would fix this, without JSON?</p>
  
  <p>Thanks</p>