How to return object value by key in php? -


i feel insane asking this, can't find answer simple question.

i have 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 return single value. thought suppose do:

return($objdata['formkey']); 

but returns php fatal error: cannot use object of type stdclass array. doing wrong?

i post data json-objec server , converts this:

$data = file_get_contents("php://input"); $objdata = json_decode($data); 

the [key] syntax accessing entry in array.

as can see dump, have object. object properties accessed ->key.

return $objdata->formkey; 

if want see error messages check log files, or enable reporting: how useful error messages in php?


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -