【问题标题】:Getting a specific array field length in php在php中获取特定的数组字段长度
【发布时间】:2015-08-06 07:02:50
【问题描述】:

我想从多维数组中获取特定的字段长度,但我不知道如何,我只能找到 sizeof(array) 或 count(array,count_recursive)

在javascript中我们可以这样做:

var modalInfo = {
                        name : 'imagePreviewModal',
                        title : 'show picture',
                        wh : [500, 400],
                        tabs : [['imagePreviewTab', body]],
                        buttons : [],
            cancelButton : false
        };
window.alert(modalInfo.tabs.length);

body in : tabs : [['imagePreviewTab',body]], is and array.

我需要的是最后一行,我可以得到 modalInfo 数组字段选项卡的长度。 我怎样才能在 php 中做同样的事情?

【问题讨论】:

  • var_dump 你的问题中来自 php 的数组/对象。

标签: javascript php arrays multidimensional-array variable-length


【解决方案1】:

这应该适合你:

$count = count($modalInfo->tabs);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-04-09
    • 1970-01-01
    • 2015-04-10
    • 1970-01-01
    • 2019-07-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多