JSON PHP Array to Javascript

后端 未结 5 1709
刺人心
刺人心 2020-12-17 04:53

Is it possible to JSON this php array via json_encode? Because this php array is called $data and when i do..

var myJson = 

        
5条回答
  •  一个人的身影
    2020-12-17 05:29

    JSON can handle any type of array (albeit it will cast associative arrays as objects). The problem you are probably facing is that you are trying to output with PHP when the data is available only on Javascript.

    To clarify: once the page has loaded, PHP cannot do anything. Only javascript can process things on client side, PHP works only on the server and has no knowledge of the state of the client.

提交回复
热议问题