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