Question about printing/echoing something from a stdClass Object?

superaff1984

Senior Member
Premium Member
Joined
Jun 16, 2010
Messages
992
Reaction score
131
Hi, I am using this $json = json_decode($resp); where $resp is my result from a CURL api connection.

Then I use this print_r($json->Bin[0]);
which on a webpage will return

stdClass Object ( [JSON_F52E2B61-18A1-11d1-B105] => {"Bin":542418,"Brand":"MASTERCARD","Bank":"CITIBANK N.A.","Type":"CREDIT","Category":"PLATINUM","IsoCountry":"UNITED STATES","Isoa2":"US","Isoa3":"USA","Isonumber":840} )

My question is how do I print/echo out ONLY the "Category" part from the stdClass Object?
 
$json = json_decode($resp);
$bin0 = $json->Bin[0]->{'JSON_F52E2B61-18A1-11d1-B105'};
$bin0Obj = json_decode($bin0);

echo $bin0Obj->Category;

I appreciate it so much! I was in a rush to get this fixed too.

One curious question I have, why does the JSON look like this: JSON JSON_F52E2B61-18A1-11d1-B1 every single time? Does this change or it always the same?
 
Back
Top