Push PHP Variable to Javascript Array -


i want push php variable javascript. code below not seem work. can show me how this?

ticks.push(<?php echo json_encode($new); ?>); 

is you're looking for?

ticks.push(json.parse('<?= json_encode($new); ?>')); 

or broken down:

var json = '<?= json_encode($new); ?>'; var obj = json.parse(json); ticks.push(obj) 

also addressed in issue:

accessing array in php javascript/jquery


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -