QuestionHow can I pass array from php to javascript?

If you will find a grammar error on this page, please select it with your mouse and press Ctrl+EnterThank you.

Hi! I am working to build a payment system. I don't understand how can I pass a PHP array to javascript. 
Name: 
lokkiii

Comments

sv2109's picture
sv2109 wrote:

You can do something like this:

<script>var js_array = $.parseJSON(<?php echo json_encode($php_array); ?>);</script>

29.10.2014 23:04

Add new comment

CAPTCHA
Spam protection
Image CAPTCHA
Enter the characters shown in the image.
You are reporting a typo in the following text:
Simply click the "Send typo report" button to complete the report. You can also include a comment.