Return a JSON object using PHP json_encode() & MySQL to pass to jQuery function

后端 未结 3 1142
攒了一身酷
攒了一身酷 2021-02-02 04:16

I\'m trying to create a json object from MySQL results, but not getting the result I need.

Here is the PHP

$json = array();
$result = m         


        
3条回答
  •  南笙
    南笙 (楼主)
    2021-02-02 04:57

    you output your json by hand and then you call json_encode on an empty array() - $json

    json_encode() outputs [] on you pass an empty array so your last [] comes from here
    $jsonstring = json_encode($json);
    echo $jsonstring;

    Edit: More about json_encode json_encode php manual

提交回复
热议问题