0
$content = $connection->get('statuses/public_timeline');

. When I use this fragment in my php file. I would like to echo $content[0].text from result array that shown below:

Array
(
[0] => stdClass Object
    (
        [in_reply_to_user_id_str] => 
        [coordinates] => 
        [geo] => 
        [user] => stdClass Object
            (
                [profile_sidebar_border_color] => a166d9
                [followers_count] => 40
                ...
            )

        [truncated] => 
        [text] => some dump text
        ...
    )
...
 )

How will I access [text] or [profile_sidebar_border_color]. What is the PHP syntax? Should I decode?

1
  • I suggest setting the 'true' flag for the 2nd arg in json encode (json_decode($your_data,true)). This makes the return data into numeric and associative arrays. I consider the mix of arrays and objects to be a pain in PHP, since the syntax is different but if the object has no methods, they do the same thing so there's no reason to mix them. Check out the json decode docs. Commented May 22, 2011 at 17:10

1 Answer 1

2

You want

$content[0]->text 

for the text and

$content[0]->user->profile_sidebar_border_color

For the user's profile sidebar border color

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

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.