How to output JSON data correctly using PHP

前端 未结 7 1469
时光说笑
时光说笑 2021-01-04 04:03

I\'m developing an Android app, and for the API I\'m sending my requests to a URL that should return JSON data.

This is what I\'m getting in my output:

7条回答
  •  礼貌的吻别
    2021-01-04 04:22

    All you have to do is to add a second argument to the json_encode method like this.

    echo json_encode($response_date, JSON_PRETTY_PRINT);
    

    or

    print json_encode($response_date, JSON_PRETTY_PRINT);
    

    You can visit this link to read more on how to use json_encode.

    Hope it helps.

提交回复
热议问题