PHP COUNT_RECURSIVE 只计算非数组值?
我有一个多维数组,其调整为 $doclist['area']['source'][#]['type']
我想获取 的所有条目的数量['type'] = "title"
不为空。
有简单的方法吗?
当我这样做时,有没有办法获取 ['type'] = "title"
AND ['area'] = "something"
的所有条目的数量> 不为空?
I have a multidimensional array to the tune of $doclist['area']['source'][#]['type']
I would like to get a number of all entries of ['type'] = "title"
that are not empty.
Is there a simple way of doing it?
While I am at it, is there a way to get a number of all entries of ['type'] = "title"
AND ['area'] = "something"
that are not empty?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
假设
'area'
和'source'
你指的是任意字符串,你可以嵌套几个循环,如下所示:Assuming by
'area'
and'source'
you mean arbitrary strings, you could nest a few loops like so:这是我根据 rfausak 的回复编写的函数:
我认为有人可能会发现它有用。
Here's the function that I wrote based on rfausak's response:
I thought that someone may find it useful.