搜索具有相关值的数组路径
我正在开发菜单系统并正在解决一些复杂的问题。菜单是从数组生成的。该数组包含在 Pastebin 中,因为它非常大。我想在数组中搜索并获取我正在搜索的值的分层路径,同时还获取您运行的父级旁边的值。正如我所说,它相当复杂。
在pastebin中是数组和我想要函数返回的结果:
I尝试编写这个函数很多次,但总是卡在中间。
I'm working on a menu system and am working on some complex issues. The menu is generated from a array. This array is included in a pastebin because it's really big. I want to search in the array and get the hierarchical path of the value I'm searching while also getting the values next to the parents you run trough. As I said its quite complex.
In the pastebin is the array and the result I want to function to return:
I tried writing this function quite a few times but always get stuck in the middle.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个功能:
我还没有测试过它,但这就是想法。
Here is a function:
I have not tested it, but this is the idea.
您基本上是在寻找构建面包屑之类的东西的路径?您可以为此使用递归函数:
像这样执行此函数:
将返回:
You are basically looking for the path to build something like a breadcrumb? You can use a recursive function for that:
Executing this function like this:
Would return: