/    Sign up×
Community /Pin to ProfileBookmark

How to parse an array of stdClass Objects

Hi Friends,

I have a string ($response) that contains this –

Array (
[0] => stdClass Object (
[in_reply_to_status_id] =>
[created_at] => Sun Feb 21 02:22:52 +0000 2010
[user] => stdClass Object (
…..[count] => 13846
…..
…..

Can someone please tell how to access the [count]. I tried this but it did not worked –

$cnt = $response[0]->user->count;

Please help
Thanks
Mick

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@dk_zero-coolFeb 21.2010 — That is the correct way of accessing the count, and it works for me.

Perhaps some more of your source code would help. I think the problem lies somewhere else.
Copy linkTweet thisAlerts:
@MindzaiFeb 21.2010 — You have a string and you want to extract that info from it? If I've understood right you will probably want to use a regular expression to extract the info from the string.

If the string was just an example of your object structure though, then your code should be fine as long as user and count both have public visibility. If so, we need more information than just 'it doesn't work'.
×

Success!

Help @mickscool spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...