PHP string array to javascript string array parsing error
arrays, javascript, php
Solution
Pretty sure because 'name' points to window.name (Thanks Fabrício Matté). Look Here
It works fine if you change 'name' to 'names'.
Problem
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?