I am trying to assign a PHP array into a javascript variable like this:
var jsArray = <?php echo $phpArray; ?>;
But it doesn't work.
What am I doing wrong?
I am trying to assign a PHP array into a javascript variable like this:
But it doesn't work. |
|||||||||
|
You should try to use JSON
accessible then via
|
||||
|
you can serialize array in php using json_encode and use it inside JS http://php.net/manual/en/function.json-encode.php
The above code outputs: {"name":"N51","data":[1024,{"y":2048,"events":{"mouseOver":"function(){$reporting.html('description of value');}"}},4096]} |
||||
|