PHP 从对象打印键? [英] PHP Print keys from an object?
本文介绍了PHP 从对象打印键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个对象 BIRD,然后有 [0] 到 [10],每个数字都有一个副标题,如虫子"或甲虫"或蚊蚋",以及每一个的值.
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屋!
查看全文