This is my data struuture:
array(6) {
["id"]=> string(15) "264729823543848"
["application"]=> array(2) {
["name"]=> string(7) "Prizzer"
["id"]=> string(15) "100398126714422"
}
["to"]=> array(2) {
["name"]=> string(18) "Danielle McPherson"
["id"]=> string(15) "100000204975672"
}
["from"]=> array(2) {
["name"]=> string(13) "Billy Zearott"
["id"]=> string(10) "1292797153"
}
["message"]=> string(45) "Become my Prizzer Buddie and win Real Prizes!"
["created_time"]=> string(24) "2011-08-02T06:06:39+0000"
}
I get this by dumping the var:
$obj = json_decode($returned_content, true);
var_dump($obj);
Now I need to extract only the value "100000204975672" which is the third id right after "Danielle McPherson". How do I do that?
Mike Samuel
121k30 gold badges230 silver badges255 bronze badges
asked Aug 3, 2011 at 12:21
Tom
9,69527 gold badges97 silver badges149 bronze badges
-
1After cleaning up your output (use code tags!), your question became a lot more clear.K4emic– K4emic2011年08月03日 12:24:30 +00:00Commented Aug 3, 2011 at 12:24
-
@K4emic: How is your edit substantially better than mine? ;) (this is not a JSON string, for example)Tomalak– Tomalak2011年08月03日 12:31:25 +00:00Commented Aug 3, 2011 at 12:31
-
itslikewhenyoudontevencareaboutwhitespaceanymore.K4emic– K4emic2011年08月03日 12:34:33 +00:00Commented Aug 3, 2011 at 12:34
-
@K4emic: Have a look at the edit history. ;-)Tomalak– Tomalak2011年08月03日 12:36:38 +00:00Commented Aug 3, 2011 at 12:36
-
Your edit is superior to mine, but the editor presented me with the original text, not your edit. Shouldn't the editor notify me that new edits were made? Apologies for the previous, slightly rude, comment.K4emic– K4emic2011年08月03日 12:42:20 +00:00Commented Aug 3, 2011 at 12:42
1 Answer 1
I had to look at your example a couple of times because of the nesting. Thanks for the edit @K4emic - much easier to read now.
echo $obj['to']['id'];
answered Aug 3, 2011 at 12:23
65Fbef05
4,5221 gold badge24 silver badges24 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-php