I have long php variable after decoding JSON string using json_decode function. object(stdClass)#1 (3) { ["responseData"]=> object(stdClass)#2 (2) { ["results"]=> array(4) { [0]=> object(stdClass)#3 (8) { ["GsearchResultClass"]=> string(10) "GwebSearch" ["unescapedUrl"]=> string(32) "http://www.example.com/Home/"........ What should be the php syntax to access highlighted portion of string/array. i want to access value of this variable ["unescapedUrl"] Please help.
We've found it's much easier to use the associative array instead of the object return value. To do this, pass 'true' as the second parameter: $array = json_decode( 'string ...', true); $unescapedUrl = $array['responseData']['results']['unescapedUrl'];
I have tried this $json = json_decode($body, true); echo $json['responseData']['results']['unescapedUrl']; PHP: It does not show anything. Than I tried following $json = json_decode($body); echo $json->$responseData->results[0]->unescapedUrl; PHP: and get this error: Fatal error: Cannot access empty property Any tips?
$json = json_decode($body); echo($json->responseData->results[0]->unescapedUrl); PHP: if that doesn't work please post the json encoded string here
Thanks Dagon. I just fixed it. I was adding $ sign before "responseData". Your code is perfect. Rep added. Thanks again.
if ( $job == "done" ) { echo "Please message me next time you have something"; } else { echo "I am interested in this job, Please Message me."; }
Eh? This was almost clever, and actually on-topic, in the other thread you posted it in but now it's kinda lame and repetitive and out of place here since this wasn't really a "job" and plus he had already posted saying it works now so.. EDIT: Wow, you actually posted this and only this in a lot of threads even threads that are just asking for help solving a problem (even when the problem was already solved like this thread). Might I suggest you not act like a spam bot?