I tried
var name = <?php echo json_encode($eventname); ?>;
and
var name = new Array("<?php echo implode('","', $eventName);?>");
to parse my array of name strings from PHP to Javascript. It is displayed as
var name = ["lalalala","Lalala","test"];
and
var name = new Array("lalalala","Lalala","test");
in viewsource, but when I tried to use the name [i] to get a string, it returned a character, not a string. The size of the array name is also not 3, but 20 (this is the total number of characters plus three ","). How can i fix this?
source share