Pretty-Printing JSON with PHP

后端 未结 24 2219
一向
一向 2020-11-22 02:03

I\'m building a PHP script that feeds JSON data to another script. My script builds data into a large associative array, and then outputs the data using json_encode

24条回答
  •  礼貌的吻别
    2020-11-22 03:07

    For those running PHP version 5.3 or before, you may try below:

    $pretty_json = "
    ".print_r(json_decode($json), true)."
    "; echo $pretty_json;

提交回复
热议问题