1

I have the folowing array:

outerarray{
            "id": "20154", 
            "from": {
              "name": "xyz", 
              "id": "10004"
            }}

Now how do i access the element name?

0

2 Answers 2

1

It is JSON, decode first using json_decode() and then access:

$arr = json_decode($yourjson, true);
echo $arr['from']['name']; // xyz

Or

$arr = json_decode($yourjson);
echo $arr->from->name; // xyz

http://php.net/manual/en/function.json-decode.php

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

Comments

0

You mus use json_decode():

$tab = json_decode($outerarray);
echo $tab['id']; //display 20154

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.