开发者

How to print properties of stdClass object in PHP?

开发者 https://www.devze.com 2023-04-12 18:10 出处:网络
I have an array that contains sta开发者_如何学Gondard class object. How can I return the properties (print them out) in a stdClass object?If you just want to print you can use var_dump() or print_r().

I have an array that contains sta开发者_如何学Gondard class object. How can I return the properties (print them out) in a stdClass object?


If you just want to print you can use var_dump() or print_r().

var_dump($obj);
print_r($obj);

If you want an array of all properties and their values use get_object_vars().

$properties = get_object_vars($obj);
print_r($properties);


you should be able to see them using var_dump($myObject);


I have solved this problem in this way:

echo $arrayName[0]->varname;

As it is an array of objects, we use -> to access objects attributes/methods.

0

精彩评论

暂无评论...
验证码 换一张
取 消