Inserting PHP array into Javascript array

bibu99

New Member
I have an array like this:\[code\]Array([0] => Array ( [id] => 9826 [tag] => "php" )[1] => Array ( [id] => 9680 [tag] => "perl" ))\[/code\]I want to pass this to a javascript variable that looks like this:\[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\]I have gotten this far:\[code\]var availableTags = [ <?php foreach($Tags as $tag){ echo $tag['tag']; } ?> ];\[/code\]the problem I have is adding the double quotes around each tag and inserting a comma after each apart from the last. I'm not sure of how to best do that?
 
Back
Top