Home > Article > Backend Development > Conversion of PHP Array to Javascript
Great programmers start with a set of pages.
1. The process of converting from PHP Array to Javascript Array
PHP Array -> PHP JSON -> Transfer -> Javascript String ->Javascript Array
2.PHP Array to JSON
<code><span>$qps_data</span> = <span>array</span>( <span>'1440743647000'</span>=><span>array</span>(<span>'x'</span>=><span>'1440743647000'</span>,<span>'y'</span>=><span>'16'</span>), <span>'1440743647000'</span>=><span>array</span>(<span>'x'</span>=><span>'1440743647000'</span>,<span>'y'</span>=><span>'16'</span>) ); <span>echo</span> json_encode(<span>$qps_data</span>);</code>
Result:
<code>{<span>"1440743647000"</span>:{<span>"x"</span>:<span>"1440743647000"</span>,<span>"y"</span>:<span>"16"</span>}}</code>
3.Javascript JSON to Array
jquery receives JSON string
<code>arrayObj = <span>eval</span>(json_string); console.<span>log</span>(arrayObj);</code>
Copyright statement: This article is an original article by the blogger and may not be reproduced without the permission of the blogger.
The above introduces the conversion of PHP Array to Javascript, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.