How can I input results of a PHP array inside a JS-file?
I have this PHP-snippet which returns an Array:
$activiteiten = Project::getProjectnames($_DB);
if(!empty($activiteiten)) {
foreach($activiteiten as $k => $v) {
$projectNames[] = $v['project'];
}
}
How can I get these values inside this JS:
<script>
$(function() {
var availableTags = [
"Option 1",
"Option 2",
"Option 3",
"Option 4"
];
$( "#tags" ).autocomplete({
source: availableTags
});
});
</script>
I want the PHP array in stead of the Option 1, Option 2, Option 3,... But how do I do this?
I'm generating the JS by using a PHP echo-call.