我正在使用一个JSON文件,它充当一个迷你数据库,它是这样布局的:
[
{
"id": "someIdentified",
"name": "someName",
"files" [
{"url": "someUrl.ext","urlDescription": "Some Description"},
{"url": "anotherUrl.ext", "urlDescrition": "Some other Description"}
]
}
{
"id": "someIdentified",
"name": "someName",
"files" [
{"url": "someUrl.ext","urlDescription": "Some Description"},
{"url": "anotherUrl.ext", "urlDescrition": "Some other Description"}
]
}
{
"id": "someIdentified",
"name": "someName",
"files" [
{"url": "someUrl.ext","urlDescription": "Some Description"},
{"url": "anotherUrl.ext", "urlDescrition": "Some other Description"}
]
}
]
如果我想检查一个值是否存在于这个对象数组中的任何地方,例如“someName”是否存在或“someUrl.ext”是否存在,并让它返回true或false,我将如何做到?我似乎可以搜索一层深,但我不知道如何搜索更深...对PHP来说还是很新的,感谢所有的指导。
1条答案
按热度按时间ohtdti5x1#
你必须进行递归搜索:
这是我做的测试: