0

I have a JSON

$data= '[
    {
        "opa": "maam",
        "clik": "7026981995",
        "pt": 123,
        "aaab": [{
            "ttt": "1.22",
            "tt": [{
                "aaa2": 1.2277,
                "aaa122": 19811225
            }]
        }]
    },
    {
        "opaa": "maam1",
        "clik1": "7026981995",
        "pt1": 123,
        "aaa11": [{
            "ttt1": "1.222",
            "tt1": [{
                "aaa1": 1.2277,
                "aaa3": 19811225
            }]
        }]
    }
]'

I need to print it on the screen, just as it is in the variable, I tried

echo json_encode($data, JSON_PRETTY_PRINT);

But, a pile is printed, not being readable.

3 Answers 3

1

how about <pre>, which is the "preformatted text element"?

die('<pre>'.print_r(json_decode($data), true).'</pre>');

this would also work (which I'd assume is what you've meant):

die('<pre>'.$data.'</pre>');
Sign up to request clarification or add additional context in comments.

Comments

0

It is already in json format. Just do:

echo $data;

Comments

0
  1. change the code to:

    print_r(json_decode($data), true)

  2. Get JSON formater extension for chrome to prettify the json.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.