php递归解析数组-查找值
我有一个 nxn 数组,我试图根据以下内容递归地获取特定值:
我想搜索特定值(针),在本例中为 'KEYVAL_TO_FIND'
如果找到的话,然后,由于数组的该部分始终具有相同的结构,因此我想获取'MY_VALUE'
。
我怎样才能做到这一点?谢谢
数组的示例(忽略键):
[0] = Array
(
[0] = Array
(
[0] = Array
[0] = KEYVAL_TO_FIND
[1] = Array
(
[0] = CONST
[1] = MY_VALUE
)
)
[1] = VAL
[2] = Array
(
[0] = FOO
[1] = BAR BAZ
)
)
I have an nxn array, which recursively I'm trying to get certain value based on the following:
I would like to search for specific value (needle), in this case 'KEYVAL_TO_FIND'
if it is found, then, since that part of the array will always have the same structure, I would like to get 'MY_VALUE'
.
How could I achieve this? Thanks
An example of how the array look like (ignore the keys):
[0] = Array
(
[0] = Array
(
[0] = Array
[0] = KEYVAL_TO_FIND
[1] = Array
(
[0] = CONST
[1] = MY_VALUE
)
)
[1] = VAL
[2] = Array
(
[0] = FOO
[1] = BAR BAZ
)
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我使用的一个功能...
我希望你喜欢它并使用它:D
祝你今天过得愉快!!
a function I use...
I hope you like it and use it :D
have a nice day!!