2

I'm doing a curl and getting the JSON result as:

$data = json_decode($result, true); var_dump($data); $data = $data["data"]; echo $data; 

However, the echo of $data is "{". If I do a var_dump before assigning again the variable I see:

string(727796) "{"data":["base64_image1", "base64_image2",... ]}" 

Why am I not able to access the data list? I just want to do a foreach over this list, but I cannot.

3
  • 2
    output is json so try to json_decode() again Commented Jun 9, 2022 at 19:34
  • Nice! It works! Write your comment as an answer and I will accept it Commented Jun 9, 2022 at 19:37
  • 5
    It would probably be better to fix the server code so it doesn't encode twice. Commented Jun 9, 2022 at 19:40

1 Answer 1

1

output is json so try to json_decode() again

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.