开发者

Php extract objects vars without cycling object itself

hi i have this object:

object(stdClass)#27 (1) {
 [0]=> object(stdClass)#26 (6){
 ["_id"]=> object(MongoId)#24 (1) {
 ["$id"]=> string(24) "4e6ea439caa47c2c0c000000" 
}
["username"]=> string(16) "wdfkewkghbrjkghb" ["email"]=> string(24) "wdhbfjkwhegerg@€rg.efg" ["password"]=> string(32) "4297f44b13955235245b2497399d7a93" ["slug"]=> string(16) "wdfkewkg开发者_Python百科hbrjkghb" ["insert_datetime"]=> string(19) "2011-09-13 12:09:49" 
} 

} 

how can i retrieve for example object->username without cycling the object?

thx

[EDITED]

this is the little piece of code i have:

$user = $this->model_user->populateBy($id = '12');
            var_dump($user);
            echo $user->username ; // error:Trying to get property of non-object  non object

doing var_dump($user); it prints out the object i pasted up.


I think get_object_vars() is what you need.

I'm not sure I understand the question though; if you want the username you can just do $Object->username..

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜