简体   繁体   中英

How to access stdclass object in php

Can anyone tell me how to access name from below code :

How to access stdclass object

stdClass Object
(
    [formdata] => [{"name":"aaa"},{"designation":""},{"organization":""},{"country":""},{"email":""},{"phone":""},{"status":""},{"interest":[]},{"comment":""},{"radio":""}]
)





you can do it like this

$obj = stdClass Object
(
 [formdata] => [{"name":"aaa"},{"designation":""},{"organization":""},{"country":""},{"email":""},{"phone":""},{"status":""},{"interest":[]},{"comment":""},{"radio":""}]
)

$newdata = json_decode(json_encode($obj), True);
$data =  json_decode($newdata['formdata'], True);
echo '<pre>';print_r($data);
 die;

it will give you and array and you can access each variables

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM