I feel insane for asking this, but I just can't find an answer to this very simple question.
I have an object: print_r:
stdClass Object
(
[formkey] => 1F9trPeu9DA4W0CjADN4a1fl3Jh682ZPF8remWB21RhI
[draftResponse] => []
[pageHistory] => 0
[entry.358412101] => asdf
[entry.898829644] => asdf
[entry.2071756716] => asdf
[entry.958924423] => asdf
)
var_dump:
object(stdClass)#1 (7) {
["formkey"]=>
string(44) "1F9trPeu9DA4W0CjADN4a1fl3Jh682ZPF8remWB21RhI"
["draftResponse"]=>
string(2) "[]"
["pageHistory"]=>
string(1) "0"
["entry.358412101"]=>
string(4) "asdf"
["entry.898829644"]=>
string(4) "asdf"
["entry.2071756716"]=>
string(4) "asdf"
["entry.958924423"]=>
string(4) "asdf"
}
I want to return a single value. I this is what thought you were suppose to do:
return($objData['formkey']);
but this returns PHP Fatal error: Cannot use object of type stdClass as array. What am I doing wrong?
I post the data as a json-objec to the server and then it converts it like this:
$data = file_get_contents("php://input");
$objData = json_decode($data);