I have an array like this:
Array
(
[0] => Array
(
[id] => 9826
[tag] => "php"
)
[1] => Array
(
[id] => 9680
[tag] => "perl"
)
)
I want to pass this to a javascript variable that looks like this:
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
];
I have gotten this far:
var availableTags = [
<?php
foreach($Tags as $tag){
echo $tag['tag'];
}
?>
];
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?