When you use json_encode
in PHP you can specify the JSON_PRETTY_PRINT
option.
echo json_encode(["foo" => ["bar" => ["baz" => "quix"]]], JSON_PRETTY_PRINT);
This gives you output like this.
{ "foo": { "bar": { "baz": "quix" } } }
If what you already have is a string you can just decode first and the encode.
$str = '{"Status":2,"TokenReg":"eeea7930efeb7715697a2035fcee3fdf","AllScores":"305","User_ID":"16433"}';
echo json_encode(json_decode($str), JSON_PRETTY_PRINT);
This should give you the desired output.
{ "Status": 2, "TokenReg": "eeea7930efeb7715697a2035fcee3fdf", "AllScores": "305", "User_ID": "16433" }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.