在 php 中获取特定的数组字段长度

Getting a specific array field length in php

我想从多维数组中获取特定的字段长度,但我不知道如何获取,而且我只能找到 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 中做同样的事情?

这应该适合你:

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