PHP从一个对象打印键? [英] PHP Print keys from an object?
本文介绍了PHP从一个对象打印键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个对象BIRD,然后有[0]到[10],每个数字都有一个小标题,例如"bug","beetle"或"gnat"以及每个值.
I have an object BIRD and then there is [0] through [10] and each number has a subheading like "bug" or "beetle" or "gnat" and a value for each of those.
我要打印
BIRD
[0]
bug = > value
我在任何地方都找不到方法-谈论PUBLIC,PRIVATE和CLASS,这就是我的失败之处
I can't find out how to do this anywhere - there is talk of PUBLIC and PRIVATE and CLASS and that's where I fall off
推荐答案
我可能是错的,但尝试使用以对象为参数的array_keys
.我相信这在php中是可能的.
http://php.net/manual/en/function.array-keys.php
I could be wrong but try to use array_keys
using a object as parameter. I believe that is possible in php.
http://php.net/manual/en/function.array-keys.php
无论如何,请阅读有关反射的文章.
Anyway, read about reflection.
这篇关于PHP从一个对象打印键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文