First off, I'm fairly new to JS and PHP. But I have a PHP array that contains the titles of some events. I'm trying to make a Javascript script that creates elements and fills them with the strings in the php array.
Here's kind of what I'm wondering about. Is there a way to do something like this:
function createCard(x) {
var event_title = "<?php echo $event_title[x]; ?>";
}
Or if there's a better way to do this, I'm open to suggestions. Thanks!
EDIT:
I was able to fix my own issue by just converting the php array into a js a array and going from there
var event_title_arr = [<?php echo '"'.implode('","', $event_title ).'"' ?>];