浏览文章

文章信息

PHP json字符串格式化输出|PHP json string format print 17919

1、方法

$map_str ='{"code": "code","msg": "msg","data": "data","data_map": "tech,auto","db_fields_map": "title=>subject,picInfo_link_digest_source=>message"}';
$map = json_decode($map_str,true);//转为数组
echo json_encode($map,JSON_PRETTY_PRINT);//格式化输出

2、输出

{
    "code": "code",
    "msg": "msg",
    "data": "data",
    "data_map": "tech,auto",
    "db_fields_map": "title=>subject,picInfo_link_digest_source=>message"
}


原创