Best method for converting a PHP array to javascript

前端 未结 4 671
无人共我
无人共我 2020-12-03 19:39

I am passing a PHP array to a javascript function. The only way I know to do this is to create a js array from the PHP array and pass that to the js function. But this creat

4条回答
  •  不知归路
    2020-12-03 20:22

    A more space-efficient way of encoding Javascript data structures is called JSON.

    As of PHP 5.2.0, you can use the following function to spit out some JSON: json_encode().

提交回复
热议问题